LCOV - code coverage report
Current view: top level - chart2/source/view/diagram - VDiagram.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 321 365 87.9 %
Date: 2012-08-25 Functions: 17 18 94.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 361 752 48.0 %

           Branch data     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 "VDiagram.hxx"
      21                 :            : #include "PropertyMapper.hxx"
      22                 :            : #include "ViewDefines.hxx"
      23                 :            : #include "Stripe.hxx"
      24                 :            : #include "macros.hxx"
      25                 :            : #include "ObjectIdentifier.hxx"
      26                 :            : #include "DiagramHelper.hxx"
      27                 :            : #include "BaseGFXHelper.hxx"
      28                 :            : #include "CommonConverters.hxx"
      29                 :            : #include "ChartTypeHelper.hxx"
      30                 :            : #include "ThreeDHelper.hxx"
      31                 :            : #include <editeng/unoprnms.hxx>
      32                 :            : #include <com/sun/star/drawing/FillStyle.hpp>
      33                 :            : #include <com/sun/star/drawing/LineStyle.hpp>
      34                 :            : #include <com/sun/star/drawing/ProjectionMode.hpp>
      35                 :            : #include <com/sun/star/drawing/ShadeMode.hpp>
      36                 :            : #include <com/sun/star/lang/XUnoTunnel.hpp>
      37                 :            : #include <com/sun/star/lang/XTypeProvider.hpp>
      38                 :            : // header for class SvxShape
      39                 :            : #include <svx/unoshape.hxx>
      40                 :            : // header for class E3dScene
      41                 :            : #include <svx/scene3d.hxx>
      42                 :            : #include <svx/e3dsceneupdater.hxx>
      43                 :            : 
      44                 :            : //.............................................................................
      45                 :            : namespace chart
      46                 :            : {
      47                 :            : //.............................................................................
      48                 :            : using namespace ::com::sun::star;
      49                 :            : using namespace ::com::sun::star::chart2;
      50                 :            : 
      51                 :        993 : VDiagram::VDiagram(
      52                 :            :     const uno::Reference< XDiagram > & xDiagram
      53                 :            :     , const drawing::Direction3D& rPreferredAspectRatio
      54                 :            :     , sal_Int32 nDimension, sal_Bool bPolar )
      55                 :            :     : m_xLogicTarget(NULL)
      56                 :            :     , m_xFinalTarget(NULL)
      57                 :            :     , m_xShapeFactory(NULL)
      58                 :            :     , m_pShapeFactory(NULL)
      59                 :            :     , m_xOuterGroupShape(NULL)
      60                 :            :     , m_xCoordinateRegionShape(NULL)
      61                 :            :     , m_xWall2D(NULL)
      62                 :            :     , m_nDimensionCount(nDimension)
      63                 :            :     , m_bPolar(bPolar)
      64                 :            :     , m_xDiagram(xDiagram)
      65                 :            :     , m_aPreferredAspectRatio(rPreferredAspectRatio)
      66                 :            :     , m_xAspectRatio3D()
      67                 :            :     , m_fXAnglePi(0)
      68                 :            :     , m_fYAnglePi(0)
      69                 :            :     , m_fZAnglePi(0)
      70 [ +  - ][ +  - ]:        993 :     , m_bRightAngledAxes(sal_False)
         [ +  - ][ +  - ]
                 [ +  - ]
      71                 :            : {
      72         [ +  + ]:        993 :     if( m_nDimensionCount == 3)
      73                 :            :     {
      74         [ +  - ]:         14 :         uno::Reference< beans::XPropertySet > xSourceProp( m_xDiagram, uno::UNO_QUERY );
      75         [ +  - ]:         14 :         ThreeDHelper::getRotationAngleFromDiagram( xSourceProp, m_fXAnglePi, m_fYAnglePi, m_fZAnglePi );
      76         [ +  - ]:         14 :         if( ChartTypeHelper::isSupportingRightAngledAxes(
      77 [ +  - ][ +  - ]:         14 :                 DiagramHelper::getChartTypeByIndex( m_xDiagram, 0 ) ) )
      78                 :            :         {
      79         [ +  - ]:         14 :             if(xSourceProp.is())
      80 [ +  - ][ +  - ]:         14 :                 xSourceProp->getPropertyValue(C2U( "RightAngledAxes" )) >>= m_bRightAngledAxes;
                 [ +  - ]
      81         [ +  + ]:         14 :             if( m_bRightAngledAxes )
      82                 :            :             {
      83         [ +  - ]:         11 :                 ThreeDHelper::adaptRadAnglesForRightAngledAxes( m_fXAnglePi, m_fYAnglePi );
      84                 :         11 :                 m_fZAnglePi=0.0;
      85                 :            :             }
      86                 :         14 :         }
      87                 :            :     }
      88                 :        993 : }
      89                 :            : 
      90                 :        993 : VDiagram::~VDiagram()
      91                 :            : {
      92 [ +  - ][ +  - ]:        993 :     delete m_pShapeFactory;
      93         [ -  + ]:        993 : }
      94                 :            : 
      95                 :        993 : void VDiagram::init(
      96                 :            :                 const uno::Reference< drawing::XShapes >& xLogicTarget
      97                 :            :               , const uno::Reference< drawing::XShapes >& xFinalTarget
      98                 :            :               , const uno::Reference< lang::XMultiServiceFactory >& xFactory )
      99                 :            : {
     100                 :            :     OSL_PRECOND(xLogicTarget.is()&&xFinalTarget.is()&&xFactory.is(),"no proper initialization parameters");
     101                 :            : 
     102                 :        993 :     m_xLogicTarget  = xLogicTarget;
     103                 :        993 :     m_xFinalTarget  = xFinalTarget;
     104                 :        993 :     m_xShapeFactory = xFactory;
     105 [ +  - ][ +  - ]:        993 :     m_pShapeFactory = new ShapeFactory(xFactory);
     106                 :        993 : }
     107                 :            : 
     108                 :        993 : void VDiagram::createShapes( const awt::Point& rPos, const awt::Size& rSize )
     109                 :            : {
     110                 :        993 :     m_aAvailablePosIncludingAxes = rPos;
     111                 :        993 :     m_aAvailableSizeIncludingAxes = rSize;
     112                 :            : 
     113         [ +  + ]:        993 :     if( m_nDimensionCount == 3 )
     114                 :         14 :         createShapes_3d();
     115                 :            :     else
     116                 :        979 :         createShapes_2d();
     117                 :        993 : }
     118                 :            : 
     119                 :       1821 : ::basegfx::B2IRectangle VDiagram::adjustPosAndSize( const awt::Point& rPos, const awt::Size& rSize )
     120                 :            : {
     121         [ +  - ]:       1821 :     ::basegfx::B2IRectangle aAllowedRect( BaseGFXHelper::makeRectangle(m_aAvailablePosIncludingAxes,m_aAvailableSizeIncludingAxes) );
     122         [ +  - ]:       1821 :     ::basegfx::B2IRectangle aNewInnerRect( BaseGFXHelper::makeRectangle(rPos,rSize) );
     123         [ +  - ]:       1821 :     aNewInnerRect.intersect( aAllowedRect );
     124                 :            : 
     125         [ +  + ]:       1821 :     if( m_nDimensionCount == 3 )
     126 [ +  - ][ +  - ]:         33 :         aNewInnerRect = adjustPosAndSize_3d( BaseGFXHelper::B2IRectangleToAWTPoint(aNewInnerRect), BaseGFXHelper::B2IRectangleToAWTSize(aNewInnerRect) );
                 [ +  - ]
     127                 :            :     else
     128 [ +  - ][ +  - ]:       1821 :         aNewInnerRect = adjustPosAndSize_2d( BaseGFXHelper::B2IRectangleToAWTPoint(aNewInnerRect), BaseGFXHelper::B2IRectangleToAWTSize(aNewInnerRect) );
                 [ +  - ]
     129                 :            : 
     130                 :       1821 :     return aNewInnerRect;
     131                 :            : }
     132                 :            : 
     133                 :       2767 : ::basegfx::B2IRectangle VDiagram::adjustPosAndSize_2d( const awt::Point& rPos, const awt::Size& rAvailableSize )
     134                 :            : {
     135                 :       2767 :     m_aCurrentPosWithoutAxes = rPos;
     136                 :       2767 :     m_aCurrentSizeWithoutAxes = rAvailableSize;
     137 [ +  + ][ +  - ]:       2767 :     if( m_aPreferredAspectRatio.DirectionX > 0 && m_aPreferredAspectRatio.DirectionY > 0)
     138                 :            :     {
     139                 :            :         //do not change aspect ratio
     140                 :            :         awt::Size  aAspectRatio( static_cast<sal_Int32>(m_aPreferredAspectRatio.DirectionX*FIXED_SIZE_FOR_3D_CHART_VOLUME),
     141                 :         57 :                                  static_cast<sal_Int32>(m_aPreferredAspectRatio.DirectionY*FIXED_SIZE_FOR_3D_CHART_VOLUME ));
     142                 :            :         m_aCurrentSizeWithoutAxes = awt::Size( ShapeFactory::calculateNewSizeRespectingAspectRatio(
     143         [ +  - ]:         57 :                         rAvailableSize, aAspectRatio ) );
     144                 :            :         //center diagram position
     145                 :            :         m_aCurrentPosWithoutAxes = awt::Point( ShapeFactory::calculateTopLeftPositionToCenterObject(
     146         [ +  - ]:         57 :             rPos, rAvailableSize, m_aCurrentSizeWithoutAxes ) );
     147                 :            : 
     148                 :            :     }
     149                 :            : 
     150         [ +  - ]:       2767 :     if( m_xWall2D.is() )
     151                 :            :     {
     152                 :       2767 :         m_xWall2D->setSize( m_aCurrentSizeWithoutAxes);
     153                 :       2767 :         m_xWall2D->setPosition(m_aCurrentPosWithoutAxes);
     154                 :            :     }
     155                 :            : 
     156                 :       2767 :     return ::basegfx::B2IRectangle( BaseGFXHelper::makeRectangle(m_aCurrentPosWithoutAxes,m_aCurrentSizeWithoutAxes) );
     157                 :            : }
     158                 :            : 
     159                 :        979 : void VDiagram::createShapes_2d()
     160                 :            : {
     161                 :            :     OSL_PRECOND(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()&&m_xShapeFactory.is(),"is not proper initialized");
     162 [ +  - ][ +  - ]:        979 :     if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()&&m_xShapeFactory.is()))
         [ +  - ][ -  + ]
                 [ +  - ]
     163                 :        979 :         return;
     164                 :            : 
     165                 :            :     //create group shape
     166         [ +  - ]:        979 :     uno::Reference< drawing::XShapes > xOuterGroup_Shapes = m_pShapeFactory->createGroup2D(m_xLogicTarget);
     167 [ +  - ][ +  - ]:        979 :     m_xOuterGroupShape = uno::Reference<drawing::XShape>( xOuterGroup_Shapes, uno::UNO_QUERY );
     168                 :            : 
     169 [ +  - ][ +  - ]:        979 :     uno::Reference< drawing::XShapes > xGroupForWall( m_pShapeFactory->createGroup2D(xOuterGroup_Shapes,C2U("PlotAreaExcludingAxes")) );
     170                 :            : 
     171                 :            :     //create independent group shape as container for datapoints and such things
     172                 :            :     {
     173 [ +  - ][ +  - ]:        979 :         uno::Reference< drawing::XShapes > xShapes = m_pShapeFactory->createGroup2D(xOuterGroup_Shapes,C2U("testonly;CooContainer=XXX_CID"));
     174 [ +  - ][ +  - ]:        979 :         m_xCoordinateRegionShape = uno::Reference<drawing::XShape>( xShapes, uno::UNO_QUERY );
     175                 :            :     }
     176                 :            : 
     177                 :            :     //---------------------------
     178         [ +  - ]:        979 :     bool bAddFloorAndWall = DiagramHelper::isSupportingFloorAndWall( m_xDiagram );
     179                 :            : 
     180                 :            :     //add back wall
     181                 :            :     {
     182                 :            :         m_xWall2D = uno::Reference< drawing::XShape >(
     183         [ +  - ]:        979 :             m_xShapeFactory->createInstance( C2U(
     184 [ +  - ][ +  - ]:        979 :             "com.sun.star.drawing.RectangleShape" ) ), uno::UNO_QUERY );
         [ +  - ][ +  - ]
     185                 :            : 
     186 [ +  - ][ +  - ]:        979 :         xGroupForWall->add(m_xWall2D);
     187         [ +  - ]:        979 :         uno::Reference< beans::XPropertySet > xProp( m_xWall2D, uno::UNO_QUERY );
     188         [ +  - ]:        979 :         if( xProp.is())
     189                 :            :         {
     190                 :            :             try
     191                 :            :             {
     192                 :            :                 OSL_ENSURE( m_xDiagram.is(), "Invalid Diagram model" );
     193         [ +  - ]:        979 :                 if( m_xDiagram.is() )
     194                 :            :                 {
     195 [ +  - ][ +  - ]:        979 :                     uno::Reference< beans::XPropertySet > xWallProp( m_xDiagram->getWall());
     196         [ +  - ]:        979 :                     if( xWallProp.is())
     197 [ +  - ][ +  - ]:        979 :                         PropertyMapper::setMappedProperties( xProp, xWallProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties() );
     198                 :            :                 }
     199         [ +  + ]:        979 :                 if( !bAddFloorAndWall )
     200                 :            :                 {
     201                 :            :                     //we always need this object as dummy object for correct scene dimensions
     202                 :            :                     //but it should not be visible in this case:
     203         [ +  - ]:         20 :                     ShapeFactory::makeShapeInvisible( m_xWall2D );
     204                 :            :                 }
     205                 :            :                 else
     206                 :            :                 {
     207                 :            :                     //CID for selection handling
     208         [ +  - ]:        959 :                     rtl::OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ) );//@todo read CID from model
     209 [ +  - ][ +  - ]:        959 :                     xProp->setPropertyValue( C2U( UNO_NAME_MISC_OBJ_NAME ), uno::makeAny( aWallCID ) );
         [ +  - ][ #  # ]
                 [ +  - ]
     210                 :            :                 }
     211                 :            :             }
     212         [ #  # ]:          0 :             catch( const uno::Exception& e )
     213                 :            :             {
     214                 :            :                 ASSERT_EXCEPTION( e );
     215                 :            :             }
     216                 :        979 :         }
     217                 :            : 
     218                 :            :     }
     219                 :            : 
     220                 :            :     //---------------------------
     221                 :            :     //position and size for diagram
     222         [ +  - ]:        979 :     adjustPosAndSize_2d( m_aAvailablePosIncludingAxes, m_aAvailableSizeIncludingAxes );
     223                 :            : }
     224                 :            : 
     225                 :         75 : E3dScene* lcl_getE3dScene( const uno::Reference< drawing::XShape >& xShape )
     226                 :            : {
     227                 :         75 :     E3dScene* pRet=NULL;
     228         [ +  - ]:         75 :     uno::Reference< lang::XUnoTunnel > xUnoTunnel( xShape, uno::UNO_QUERY );
     229         [ +  - ]:         75 :     uno::Reference< lang::XTypeProvider > xTypeProvider( xShape, uno::UNO_QUERY );
     230 [ +  - ][ +  - ]:         75 :     if(xUnoTunnel.is()&&xTypeProvider.is())
                 [ +  - ]
     231                 :            :     {
     232 [ +  - ][ +  - ]:         75 :         SvxShape* pSvxShape = reinterpret_cast<SvxShape*>(xUnoTunnel->getSomething( SvxShape::getUnoTunnelId() ));
     233         [ +  - ]:         75 :         if(pSvxShape)
     234                 :            :         {
     235         [ +  - ]:         75 :             SdrObject* pObj = pSvxShape->GetSdrObject();
     236 [ +  - ][ +  - ]:         75 :             if( pObj && pObj->ISA(E3dScene) )
         [ +  - ][ +  - ]
                 [ +  - ]
     237                 :         75 :                 pRet = (E3dScene*)pObj;
     238                 :            :         }
     239                 :            :     }
     240                 :         75 :     return pRet;
     241                 :            : }
     242                 :            : 
     243                 :         14 : void lcl_setLightSources(
     244                 :            :     const uno::Reference< beans::XPropertySet > & xSource,
     245                 :            :     const uno::Reference< beans::XPropertySet > & xDest )
     246                 :            : {
     247                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_1 ),
     248 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_1 )));
                 [ +  - ]
     249                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_2 ),
     250 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_2 )));
                 [ +  - ]
     251                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_3 ),
     252 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_3 )));
                 [ +  - ]
     253                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_4 ),
     254 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_4 )));
                 [ +  - ]
     255                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_5 ),
     256 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_5 )));
                 [ +  - ]
     257                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_6 ),
     258 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_6 )));
                 [ +  - ]
     259                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_7 ),
     260 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_7 )));
                 [ +  - ]
     261                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_8 ),
     262 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTON_8 )));
                 [ +  - ]
     263                 :            : 
     264                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_1 ),
     265 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_1 )));
                 [ +  - ]
     266                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_2 ),
     267 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_2 )));
                 [ +  - ]
     268                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_3 ),
     269 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_3 )));
                 [ +  - ]
     270                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_4 ),
     271 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_4 )));
                 [ +  - ]
     272                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_5 ),
     273 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_5 )));
                 [ +  - ]
     274                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_6 ),
     275 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_6 )));
                 [ +  - ]
     276                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_7 ),
     277 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_7 )));
                 [ +  - ]
     278                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_8 ),
     279 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTDIRECTION_8 )));
                 [ +  - ]
     280                 :            : 
     281                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_1 ),
     282 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_1 )));
                 [ +  - ]
     283                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_2 ),
     284 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_2 )));
                 [ +  - ]
     285                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_3 ),
     286 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_3 )));
                 [ +  - ]
     287                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_4 ),
     288 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_4 )));
                 [ +  - ]
     289                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_5 ),
     290 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_5 )));
                 [ +  - ]
     291                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_6 ),
     292 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_6 )));
                 [ +  - ]
     293                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_7 ),
     294 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_7 )));
                 [ +  - ]
     295                 :         14 :     xDest->setPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_8 ),
     296 [ +  - ][ +  - ]:         14 :                              xSource->getPropertyValue( C2U( UNO_NAME_3D_SCENE_LIGHTCOLOR_8 )));
                 [ +  - ]
     297                 :         14 : }
     298                 :            : 
     299                 :            : namespace
     300                 :            : {
     301                 :            : 
     302                 :         47 : void lcl_ensureScaleValue( double& rfScale )
     303                 :            : {
     304                 :            :     OSL_ENSURE(rfScale>0, "calculation error for automatic 3D height in chart");
     305         [ -  + ]:         47 :     if( rfScale<0 )
     306                 :          0 :         rfScale = 1.0;
     307         [ -  + ]:         47 :     else if( rfScale<0.2 )
     308                 :          0 :         rfScale = 0.2;
     309         [ -  + ]:         47 :     else if( rfScale>5.0 )
     310                 :          0 :         rfScale = 5.0;
     311                 :         47 : }
     312                 :            : 
     313                 :            : }
     314                 :            : 
     315                 :         47 : void VDiagram::adjustAspectRatio3d( const awt::Size& rAvailableSize )
     316                 :            : {
     317                 :            :     OSL_PRECOND(m_xAspectRatio3D.is(), "created shape offers no XPropertySet");
     318         [ +  - ]:         47 :     if( m_xAspectRatio3D.is())
     319                 :            :     {
     320                 :            :         try
     321                 :            :         {
     322                 :         47 :             double fScaleX = m_aPreferredAspectRatio.DirectionX;
     323                 :         47 :             double fScaleY = m_aPreferredAspectRatio.DirectionY;
     324                 :         47 :             double fScaleZ = m_aPreferredAspectRatio.DirectionZ;
     325                 :            : 
     326                 :            :             //normalize scale factors
     327                 :            :             {
     328 [ +  - ][ +  - ]:         47 :                 double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ );
     329                 :         47 :                 fScaleX/=fMax;
     330                 :         47 :                 fScaleY/=fMax;
     331                 :         47 :                 fScaleZ/=fMax;
     332                 :            :             }
     333                 :            : 
     334 [ +  - ][ -  + ]:         47 :             if( fScaleX<0 || fScaleY<0 || fScaleZ<0 )
                 [ #  # ]
     335                 :            :             {
     336                 :            :                 //calculate automatic 3D aspect ratio that fits good into the given 2D area
     337                 :         47 :                 double fW = rAvailableSize.Width;
     338                 :         47 :                 double fH = rAvailableSize.Height;
     339                 :            : 
     340                 :         47 :                 double sx = fabs(sin(m_fXAnglePi));
     341                 :         47 :                 double sy = fabs(sin(m_fYAnglePi));
     342                 :         47 :                 double cz = fabs(cos(m_fZAnglePi));
     343                 :         47 :                 double sz = fabs(sin(m_fZAnglePi));
     344                 :            : 
     345         [ +  + ]:         47 :                 if(m_bRightAngledAxes)
     346                 :            :                 {
     347                 :            :                     //base equations:
     348                 :            :                     //fH*zoomfactor == sx*fScaleZ + fScaleY;
     349                 :            :                     //fW*zoomfactor == sy*fScaleZ + fScaleX;
     350                 :            : 
     351 [ +  - ][ +  - ]:         44 :                     if( fScaleX>0 && fScaleZ>0 )
     352                 :            :                     {
     353                 :            :                         //calculate fScaleY:
     354         [ +  - ]:         88 :                         if( !::basegfx::fTools::equalZero(fW) )
     355                 :            :                         {
     356                 :         44 :                             fScaleY = (fH/fW)*(sy*fScaleZ+fScaleX)-(sx*fScaleZ);
     357                 :         44 :                             lcl_ensureScaleValue( fScaleY );
     358                 :            :                         }
     359                 :            :                         else
     360                 :          0 :                             fScaleY = 1.0;//looking from top or bottom the height is irrelevant
     361                 :            :                     }
     362 [ #  # ][ #  # ]:          0 :                     else if( fScaleY>0 && fScaleZ>0 )
     363                 :            :                     {
     364                 :            :                         //calculate fScaleX:
     365         [ #  # ]:          0 :                         if( !::basegfx::fTools::equalZero(fH) )
     366                 :            :                         {
     367                 :          0 :                             fScaleX = (fW/fH)*(sx*fScaleZ+fScaleY)-(sy*fScaleZ);
     368                 :          0 :                             lcl_ensureScaleValue(fScaleX);
     369                 :            :                         }
     370                 :            :                         else
     371                 :          0 :                             fScaleX = 1.0;//looking from top or bottom hieght is irrelevant
     372                 :            :                     }
     373                 :            :                     else
     374                 :            :                     {
     375                 :            :                         //todo
     376                 :            :                         OSL_FAIL("not implemented yet");
     377                 :            : 
     378         [ #  # ]:          0 :                         if( fScaleX<0 )
     379                 :          0 :                             fScaleX = 1.0;
     380         [ #  # ]:          0 :                         if( fScaleY<0 )
     381                 :          0 :                             fScaleY = 1.0;
     382         [ #  # ]:          0 :                         if( fScaleZ<0 )
     383                 :         44 :                             fScaleZ = 1.0;
     384                 :            :                     }
     385                 :            :                 }
     386                 :            :                 else
     387                 :            :                 {
     388                 :            :                     //base equations:
     389                 :            :                     //fH*zoomfactor == cz*fScaleY + sz*fScaleX;
     390                 :            :                     //fW*zoomfactor == cz*fScaleX + sz*fScaleY;
     391                 :            :                     //==>  fScaleY*(fH*sz-fW*cz) == fScaleX*(fW*sz-fH*cz);
     392 [ +  - ][ +  - ]:          3 :                     if( fScaleX>0 && fScaleZ>0 )
     393                 :            :                     {
     394                 :            :                         //calculate fScaleY:
     395                 :          3 :                         double fDivide = fH*sz-fW*cz;
     396         [ +  - ]:          3 :                         if( !::basegfx::fTools::equalZero(fDivide) )
     397                 :            :                         {
     398                 :          3 :                             fScaleY = fScaleX*(fW*sz-fH*cz) / fDivide;
     399                 :          3 :                             lcl_ensureScaleValue(fScaleY);
     400                 :            :                         }
     401                 :            :                         else
     402                 :          3 :                             fScaleY = 1.0;//looking from top or bottom the height is irrelevant
     403                 :            : 
     404                 :            :                     }
     405 [ #  # ][ #  # ]:          0 :                     else if( fScaleY>0 && fScaleZ>0 )
     406                 :            :                     {
     407                 :            :                         //calculate fScaleX:
     408                 :          0 :                         double fDivide = fW*sz-fH*cz;
     409         [ #  # ]:          0 :                         if( !::basegfx::fTools::equalZero(fDivide) )
     410                 :            :                         {
     411                 :          0 :                             fScaleX = fScaleY*(fH*sz-fW*cz) / fDivide;
     412                 :          0 :                             lcl_ensureScaleValue(fScaleX);
     413                 :            :                         }
     414                 :            :                         else
     415                 :          0 :                             fScaleX = 1.0;//looking from top or bottom hieght is irrelevant
     416                 :            :                     }
     417                 :            :                     else
     418                 :            :                     {
     419                 :            :                         //todo
     420                 :            :                         OSL_FAIL("not implemented yet");
     421                 :            : 
     422         [ #  # ]:          0 :                         if( fScaleX<0 )
     423                 :          0 :                             fScaleX = 1.0;
     424         [ #  # ]:          0 :                         if( fScaleY<0 )
     425                 :          0 :                             fScaleY = 1.0;
     426         [ #  # ]:          0 :                         if( fScaleZ<0 )
     427                 :         47 :                             fScaleZ = 1.0;
     428                 :            :                     }
     429                 :            :                 }
     430                 :            :             }
     431                 :            : 
     432                 :            :             //normalize scale factors
     433                 :            :             {
     434 [ +  - ][ +  - ]:         47 :                 double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ );
     435                 :         47 :                 fScaleX/=fMax;
     436                 :         47 :                 fScaleY/=fMax;
     437                 :         47 :                 fScaleZ/=fMax;
     438                 :            :             }
     439                 :            : 
     440                 :            :             // identity matrix
     441         [ +  - ]:         47 :             ::basegfx::B3DHomMatrix aResult;
     442                 :            :             aResult.translate( -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0,
     443                 :            :                             -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0,
     444         [ +  - ]:         47 :                             -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 );
     445         [ +  - ]:         47 :             aResult.scale( fScaleX, fScaleY, fScaleZ );
     446                 :            :             aResult.translate( FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0,
     447                 :            :                             FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0,
     448         [ +  - ]:         47 :                             FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 );
     449                 :            : 
     450                 :            :             // To get the 3D aspect ratio's effect on the 2D scene size, the scene's 2D size needs to be adapted to
     451                 :            :             // 3D content changes here. The tooling class remembers the current 3D transformation stack
     452                 :            :             // and in it's destructor, calculates a new 2D SnapRect for the scene and it's modified 3D geometry.
     453 [ +  - ][ +  - ]:         47 :             E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene( m_xOuterGroupShape ));
     454                 :            : 
     455         [ +  - ]:         47 :             m_xAspectRatio3D->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX )
     456 [ +  - ][ +  - ]:         47 :                 , uno::makeAny(BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aResult )) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ #  # ]
     457                 :            :         }
     458                 :          0 :         catch( const uno::Exception& e )
     459                 :            :         {
     460                 :            :             ASSERT_EXCEPTION( e );
     461                 :            :         }
     462                 :            :     }
     463                 :         47 : }
     464                 :            : 
     465                 :         47 : ::basegfx::B2IRectangle VDiagram::adjustPosAndSize_3d( const awt::Point& rPos, const awt::Size& rAvailableSize )
     466                 :            : {
     467                 :         47 :     adjustAspectRatio3d( rAvailableSize );
     468                 :            : 
     469                 :            :     //do not change aspect ratio of 3D scene with 2D bound rect
     470                 :            :     m_aCurrentSizeWithoutAxes = ShapeFactory::calculateNewSizeRespectingAspectRatio(
     471         [ +  - ]:         47 :                     rAvailableSize, m_xOuterGroupShape->getSize() );
     472                 :         47 :     m_xOuterGroupShape->setSize( m_aCurrentSizeWithoutAxes );
     473                 :            : 
     474                 :            :     //center diagram position
     475                 :            :     m_aCurrentPosWithoutAxes= ShapeFactory::calculateTopLeftPositionToCenterObject(
     476                 :         47 :          rPos, rAvailableSize, m_aCurrentSizeWithoutAxes );
     477                 :         47 :     m_xOuterGroupShape->setPosition(m_aCurrentPosWithoutAxes);
     478                 :            : 
     479                 :         47 :     return ::basegfx::B2IRectangle( BaseGFXHelper::makeRectangle(m_aCurrentPosWithoutAxes,m_aCurrentSizeWithoutAxes) );
     480                 :            : }
     481                 :            : 
     482                 :         14 : void VDiagram::createShapes_3d()
     483                 :            : {
     484                 :            :     OSL_PRECOND(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()&&m_xShapeFactory.is(),"is not proper initialized");
     485 [ +  - ][ +  - ]:         14 :     if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is()&&m_xShapeFactory.is()))
         [ +  - ][ -  + ]
                 [ +  - ]
     486                 :         14 :         return;
     487                 :            : 
     488                 :            :     //create shape
     489                 :            :     m_xOuterGroupShape = uno::Reference< drawing::XShape >(
     490         [ +  - ]:         14 :             m_xShapeFactory->createInstance( C2U(
     491 [ +  - ][ +  - ]:         14 :             "com.sun.star.drawing.Shape3DSceneObject" ) ), uno::UNO_QUERY );
         [ +  - ][ +  - ]
     492 [ +  - ][ +  - ]:         14 :     ShapeFactory::setShapeName( m_xOuterGroupShape, C2U("PlotAreaExcludingAxes") );
     493 [ +  - ][ +  - ]:         14 :     m_xLogicTarget->add(m_xOuterGroupShape);
     494                 :            : 
     495                 :            :     uno::Reference< drawing::XShapes > xOuterGroup_Shapes =
     496         [ +  - ]:         14 :             uno::Reference<drawing::XShapes>( m_xOuterGroupShape, uno::UNO_QUERY );
     497                 :            : 
     498                 :            : 
     499                 :            :     //-------------------------------------------------------------------------
     500                 :            :     //create additional group to manipulate the aspect ratio of the whole diagram:
     501 [ +  - ][ +  - ]:         14 :     xOuterGroup_Shapes = m_pShapeFactory->createGroup3D( xOuterGroup_Shapes, rtl::OUString() );
     502                 :            : 
     503 [ +  - ][ +  - ]:         14 :     m_xAspectRatio3D = uno::Reference< beans::XPropertySet >( xOuterGroup_Shapes, uno::UNO_QUERY );
     504                 :            : 
     505                 :            :     //---------------------------
     506                 :            : 
     507         [ +  - ]:         14 :     bool bAddFloorAndWall = DiagramHelper::isSupportingFloorAndWall( m_xDiagram );
     508                 :            : 
     509                 :         14 :     const bool bDoubleSided = false;
     510                 :         14 :     const bool bFlatNormals = true;
     511                 :            : 
     512                 :            :     //add walls
     513                 :            :     {
     514         [ +  - ]:         14 :         uno::Reference< beans::XPropertySet > xWallProp( NULL );
     515         [ +  - ]:         14 :         if( m_xDiagram.is() )
     516 [ +  - ][ +  - ]:         14 :             xWallProp=uno::Reference< beans::XPropertySet >( m_xDiagram->getWall());
                 [ +  - ]
     517                 :            : 
     518         [ +  - ]:         14 :         rtl::OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ) );//@todo read CID from model
     519         [ -  + ]:         14 :         if( !bAddFloorAndWall )
     520                 :          0 :             aWallCID = rtl::OUString();
     521         [ +  - ]:         14 :         uno::Reference< drawing::XShapes > xWallGroup_Shapes( m_pShapeFactory->createGroup3D( xOuterGroup_Shapes, aWallCID ) );
     522                 :            : 
     523 [ +  - ][ +  - ]:         14 :         CuboidPlanePosition eLeftWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeftWall( uno::Reference< beans::XPropertySet >( m_xDiagram, uno::UNO_QUERY ) ) );
     524 [ +  - ][ +  - ]:         14 :         CuboidPlanePosition eBackWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBackWall( uno::Reference< beans::XPropertySet >( m_xDiagram, uno::UNO_QUERY ) ) );
     525                 :            : 
     526                 :            :         //add left wall
     527                 :            :         {
     528         [ -  + ]:         14 :             short nRotatedTexture = ( CuboidPlanePosition_Front==eBackWallPos ) ? 3 : 1;
     529                 :         14 :             double xPos = 0.0;
     530         [ -  + ]:         14 :             if( CuboidPlanePosition_Right==eLeftWallPos )
     531                 :          0 :                 xPos = FIXED_SIZE_FOR_3D_CHART_VOLUME;
     532                 :            :             Stripe aStripe( drawing::Position3D(xPos,FIXED_SIZE_FOR_3D_CHART_VOLUME,0)
     533                 :            :                 , drawing::Direction3D(0,0,FIXED_SIZE_FOR_3D_CHART_VOLUME)
     534         [ +  - ]:         14 :                 , drawing::Direction3D(0,-FIXED_SIZE_FOR_3D_CHART_VOLUME,0) );
     535         [ -  + ]:         14 :             if( CuboidPlanePosition_Right==eLeftWallPos )
     536                 :            :             {
     537         [ #  # ]:          0 :                 nRotatedTexture = ( CuboidPlanePosition_Front==eBackWallPos ) ? 2 : 0;
     538                 :            :                 aStripe = Stripe( drawing::Position3D(xPos,FIXED_SIZE_FOR_3D_CHART_VOLUME,0)
     539                 :            :                     , drawing::Direction3D(0,-FIXED_SIZE_FOR_3D_CHART_VOLUME,0)
     540         [ #  # ]:          0 :                     , drawing::Direction3D(0,0,FIXED_SIZE_FOR_3D_CHART_VOLUME) );
     541                 :            :             }
     542         [ +  - ]:         14 :             aStripe.InvertNormal(true);
     543                 :            : 
     544                 :            :             uno::Reference< drawing::XShape > xShape =
     545                 :            :                 m_pShapeFactory->createStripe( xWallGroup_Shapes, aStripe
     546 [ +  - ][ +  - ]:         14 :                     , xWallProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), bDoubleSided, nRotatedTexture, bFlatNormals );
     547         [ -  + ]:         14 :             if( !bAddFloorAndWall )
     548                 :            :             {
     549                 :            :                 //we always need this object as dummy object for correct scene dimensions
     550                 :            :                 //but it should not be visible in this case:
     551         [ #  # ]:          0 :                 ShapeFactory::makeShapeInvisible( xShape );
     552                 :         14 :             }
     553                 :            :         }
     554                 :            :         //add back wall
     555                 :            :         {
     556                 :         14 :             short nRotatedTexture = 0;
     557                 :         14 :             double zPos = 0.0;
     558         [ -  + ]:         14 :             if( CuboidPlanePosition_Front==eBackWallPos )
     559                 :          0 :                     zPos = FIXED_SIZE_FOR_3D_CHART_VOLUME;
     560                 :            :             Stripe aStripe( drawing::Position3D(0,FIXED_SIZE_FOR_3D_CHART_VOLUME,zPos)
     561                 :            :                 , drawing::Direction3D(0,-FIXED_SIZE_FOR_3D_CHART_VOLUME,0)
     562         [ +  - ]:         14 :                 , drawing::Direction3D(FIXED_SIZE_FOR_3D_CHART_VOLUME,0,0) );
     563         [ -  + ]:         14 :             if( CuboidPlanePosition_Front==eBackWallPos )
     564                 :            :             {
     565                 :            :                 aStripe = Stripe( drawing::Position3D(0,FIXED_SIZE_FOR_3D_CHART_VOLUME,zPos)
     566                 :            :                 , drawing::Direction3D(FIXED_SIZE_FOR_3D_CHART_VOLUME,0,0)
     567         [ #  # ]:          0 :                 , drawing::Direction3D(0,-FIXED_SIZE_FOR_3D_CHART_VOLUME,0) );
     568                 :          0 :                 nRotatedTexture = 3;
     569                 :            :             }
     570         [ +  - ]:         14 :             aStripe.InvertNormal(true);
     571                 :            : 
     572                 :            :             uno::Reference< drawing::XShape > xShape =
     573                 :            :                 m_pShapeFactory->createStripe(xWallGroup_Shapes, aStripe
     574 [ +  - ][ +  - ]:         14 :                     , xWallProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), bDoubleSided, nRotatedTexture, bFlatNormals );
     575         [ -  + ]:         14 :             if( !bAddFloorAndWall )
     576                 :            :             {
     577                 :            :                 //we always need this object as dummy object for correct scene dimensions
     578                 :            :                 //but it should not be visible in this case:
     579         [ #  # ]:          0 :                 ShapeFactory::makeShapeInvisible( xShape );
     580                 :         14 :             }
     581                 :         14 :         }
     582                 :            :     }
     583                 :            : 
     584                 :            :     try
     585                 :            :     {
     586         [ +  - ]:         14 :         uno::Reference< beans::XPropertySet > xSourceProp( m_xDiagram, uno::UNO_QUERY_THROW );
     587         [ +  - ]:         14 :         uno::Reference< beans::XPropertySet > xDestProp( m_xOuterGroupShape, uno::UNO_QUERY_THROW );
     588                 :            : 
     589                 :            :         //perspective
     590                 :            :         {
     591                 :            :             //ignore distance and focal length from file format and model comcpletely
     592                 :            :             //use vrp only to indicate the distance of the camera and thus influence the perspecitve
     593         [ +  - ]:         14 :             xDestProp->setPropertyValue( C2U( UNO_NAME_3D_SCENE_DISTANCE ), uno::makeAny(
     594 [ +  - ][ +  - ]:         14 :                                         static_cast<sal_Int32>(ThreeDHelper::getCameraDistance( xSourceProp ))));
         [ +  - ][ +  - ]
     595         [ +  - ]:         14 :             xDestProp->setPropertyValue( C2U( UNO_NAME_3D_SCENE_PERSPECTIVE ),
     596 [ +  - ][ +  - ]:         14 :                                         xSourceProp->getPropertyValue( C2U( UNO_NAME_3D_SCENE_PERSPECTIVE )));
         [ +  - ][ +  - ]
                 [ +  - ]
     597                 :            :         }
     598                 :            : 
     599                 :            :         //light
     600                 :            :         {
     601         [ +  - ]:         14 :             xDestProp->setPropertyValue( C2U( UNO_NAME_3D_SCENE_SHADE_MODE ),
     602 [ +  - ][ +  - ]:         14 :                                         xSourceProp->getPropertyValue( C2U( UNO_NAME_3D_SCENE_SHADE_MODE )));
         [ +  - ][ +  - ]
                 [ +  - ]
     603         [ +  - ]:         14 :             xDestProp->setPropertyValue( C2U( UNO_NAME_3D_SCENE_AMBIENTCOLOR ),
     604 [ +  - ][ +  - ]:         14 :                                         xSourceProp->getPropertyValue( C2U( UNO_NAME_3D_SCENE_AMBIENTCOLOR )));
         [ +  - ][ +  - ]
                 [ +  - ]
     605         [ +  - ]:         14 :             xDestProp->setPropertyValue( C2U( UNO_NAME_3D_SCENE_TWO_SIDED_LIGHTING ),
     606 [ +  - ][ +  - ]:         14 :                                         xSourceProp->getPropertyValue( C2U( UNO_NAME_3D_SCENE_TWO_SIDED_LIGHTING )));
         [ +  - ][ +  - ]
                 [ +  - ]
     607         [ +  - ]:         14 :             lcl_setLightSources( xSourceProp, xDestProp );
     608                 :            :         }
     609                 :            : 
     610                 :            :         //rotation
     611                 :            :         {
     612                 :            :             //set diagrams rotation is set exclusively vie the transformation matrix
     613                 :            :             //don't set a camera at all!
     614                 :            :             //the cameras rotation is incorporated into this matrix
     615                 :            : 
     616         [ +  - ]:         14 :             ::basegfx::B3DHomMatrix aEffectiveTranformation;
     617         [ +  - ]:         14 :             aEffectiveTranformation.translate(-FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0);
     618                 :            : 
     619         [ +  + ]:         14 :             if(!m_bRightAngledAxes)
     620         [ +  - ]:          3 :                 aEffectiveTranformation.rotate(m_fXAnglePi,m_fYAnglePi,m_fZAnglePi);
     621                 :            :             else
     622         [ +  - ]:         11 :                 aEffectiveTranformation.shearXY(m_fYAnglePi,-m_fXAnglePi);
     623                 :            : 
     624                 :            :             //#i98497# 3D charts are rendered with wrong size
     625 [ +  - ][ +  - ]:         14 :             E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene( m_xOuterGroupShape ));
     626         [ +  - ]:         14 :             xDestProp->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX ),
     627 [ +  - ][ +  - ]:         14 :                     uno::makeAny( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aEffectiveTranformation ) ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     628         [ #  # ]:         14 :         }
     629                 :            :     }
     630         [ #  # ]:          0 :     catch( const uno::Exception & ex )
     631                 :            :     {
     632                 :            :         ASSERT_EXCEPTION( ex );
     633                 :            :     }
     634                 :            : 
     635                 :            :     //add floor plate
     636                 :            :     {
     637         [ +  - ]:         14 :         uno::Reference< beans::XPropertySet > xFloorProp( NULL );
     638         [ +  - ]:         14 :         if( m_xDiagram.is() )
     639 [ +  - ][ +  - ]:         14 :             xFloorProp=uno::Reference< beans::XPropertySet >( m_xDiagram->getFloor());
                 [ +  - ]
     640                 :            : 
     641                 :            :         Stripe aStripe( drawing::Position3D(0,0,0)
     642                 :            :             , drawing::Direction3D(0,0,FIXED_SIZE_FOR_3D_CHART_VOLUME)
     643         [ +  - ]:         14 :             , drawing::Direction3D(FIXED_SIZE_FOR_3D_CHART_VOLUME,0,0) );
     644         [ +  - ]:         14 :         aStripe.InvertNormal(true);
     645                 :            : 
     646                 :            :         uno::Reference< drawing::XShape > xShape =
     647                 :            :             m_pShapeFactory->createStripe(xOuterGroup_Shapes, aStripe
     648 [ +  - ][ +  - ]:         14 :                 , xFloorProp, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), bDoubleSided, 0, bFlatNormals );
     649                 :            : 
     650 [ +  - ][ +  - ]:         14 :         CuboidPlanePosition eBottomPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBottom( uno::Reference< beans::XPropertySet >( m_xDiagram, uno::UNO_QUERY ) ) );
     651 [ -  + ][ +  - ]:         14 :         if( !bAddFloorAndWall || (CuboidPlanePosition_Bottom!=eBottomPos) )
     652                 :            :         {
     653                 :            :             //we always need this object as dummy object for correct scene dimensions
     654                 :            :             //but it should not be visible in this case:
     655         [ #  # ]:          0 :             ShapeFactory::makeShapeInvisible( xShape );
     656                 :            :         }
     657                 :            :         else
     658                 :            :         {
     659         [ +  - ]:         14 :             rtl::OUString aFloorCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_FLOOR, rtl::OUString() ) );//@todo read CID from model
     660         [ +  - ]:         14 :             ShapeFactory::setShapeName( xShape, aFloorCID );
     661                 :         14 :         }
     662                 :            :     }
     663                 :            :     //---------------------------
     664                 :            : 
     665                 :            :     //create an additional scene for the smaller inner coordinate region:
     666                 :            :     {
     667 [ +  - ][ +  - ]:         14 :         uno::Reference< drawing::XShapes > xShapes = m_pShapeFactory->createGroup3D( xOuterGroup_Shapes,C2U("testonly;CooContainer=XXX_CID") );
     668 [ +  - ][ +  - ]:         14 :         m_xCoordinateRegionShape = uno::Reference< drawing::XShape >( xShapes, uno::UNO_QUERY );
     669                 :            : 
     670         [ +  - ]:         14 :         uno::Reference< beans::XPropertySet > xShapeProp( m_xCoordinateRegionShape, uno::UNO_QUERY );
     671                 :            :         OSL_ENSURE(xShapeProp.is(), "created shape offers no XPropertySet");
     672         [ +  - ]:         14 :         if( xShapeProp.is())
     673                 :            :         {
     674                 :            :             try
     675                 :            :             {
     676                 :         14 :                 double fXScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME;
     677                 :         14 :                 double fYScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME;
     678                 :         14 :                 double fZScale = (FIXED_SIZE_FOR_3D_CHART_VOLUME -GRID_TO_WALL_DISTANCE) /FIXED_SIZE_FOR_3D_CHART_VOLUME;
     679                 :            : 
     680         [ +  - ]:         14 :                 ::basegfx::B3DHomMatrix aM;
     681         [ +  - ]:         14 :                 aM.translate(GRID_TO_WALL_DISTANCE/fXScale, GRID_TO_WALL_DISTANCE/fYScale, GRID_TO_WALL_DISTANCE/fZScale);
     682         [ +  - ]:         14 :                 aM.scale( fXScale, fYScale, fZScale );
     683 [ +  - ][ +  - ]:         14 :                 E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene( m_xOuterGroupShape ));
     684         [ +  - ]:         14 :                 xShapeProp->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX )
     685 [ +  - ][ +  - ]:         14 :                     , uno::makeAny(BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aM)) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ #  # ]
     686                 :            :             }
     687         [ #  # ]:          0 :             catch( const uno::Exception& e )
     688                 :            :             {
     689                 :            :                 ASSERT_EXCEPTION( e );
     690                 :            :             }
     691                 :         14 :         }
     692                 :            :     }
     693                 :            : 
     694                 :         14 :     m_aCurrentPosWithoutAxes = m_aAvailablePosIncludingAxes;
     695                 :         14 :     m_aCurrentSizeWithoutAxes = m_aAvailableSizeIncludingAxes;
     696         [ +  - ]:         14 :     adjustPosAndSize_3d( m_aAvailablePosIncludingAxes, m_aAvailableSizeIncludingAxes );
     697                 :            : }
     698                 :            : 
     699                 :        993 : uno::Reference< drawing::XShapes > VDiagram::getCoordinateRegion()
     700                 :            : {
     701                 :        993 :     return uno::Reference<drawing::XShapes>( m_xCoordinateRegionShape, uno::UNO_QUERY );
     702                 :            : }
     703                 :            : 
     704                 :       4155 : ::basegfx::B2IRectangle VDiagram::getCurrentRectangle()
     705                 :            : {
     706                 :       4155 :     return BaseGFXHelper::makeRectangle(m_aCurrentPosWithoutAxes,m_aCurrentSizeWithoutAxes);
     707                 :            : }
     708                 :            : 
     709                 :        617 : void VDiagram::reduceToMimimumSize()
     710                 :            : {
     711         [ +  - ]:        617 :     if( m_xOuterGroupShape.is() )
     712                 :            :     {
     713                 :        617 :         awt::Size aMaxSize( m_aAvailableSizeIncludingAxes );
     714                 :        617 :         awt::Point aMaxPos( m_aAvailablePosIncludingAxes );
     715                 :            : 
     716                 :        617 :         sal_Int32 nNewWidth = aMaxSize.Width/3;
     717                 :        617 :         sal_Int32 nNewHeight = aMaxSize.Height/3;
     718                 :        617 :         awt::Size aNewSize( nNewWidth, nNewHeight );
     719                 :        617 :         awt::Point aNewPos( aMaxPos );
     720                 :        617 :         aNewPos.X += nNewWidth;
     721                 :        617 :         aNewPos.Y += nNewHeight;
     722                 :            : 
     723         [ +  - ]:        617 :         adjustPosAndSize( aNewPos, aNewSize );
     724                 :            :     }
     725                 :        617 : }
     726                 :            : 
     727                 :       1204 : ::basegfx::B2IRectangle VDiagram::adjustInnerSize( const ::basegfx::B2IRectangle& rConsumedOuterRect )
     728                 :            : {
     729                 :       1204 :     awt::Point aNewPos( m_aCurrentPosWithoutAxes );
     730                 :       1204 :     awt::Size aNewSize( m_aCurrentSizeWithoutAxes );
     731                 :            : 
     732                 :            :     ::basegfx::B2IRectangle rAvailableOuterRect(
     733         [ +  - ]:       1204 :         BaseGFXHelper::makeRectangle(m_aAvailablePosIncludingAxes,m_aAvailableSizeIncludingAxes) );
     734                 :            : 
     735 [ +  - ][ +  - ]:       1204 :     sal_Int32 nDeltaWidth = static_cast<sal_Int32>(rAvailableOuterRect.getWidth() - rConsumedOuterRect.getWidth());
     736 [ +  - ][ +  - ]:       1204 :     sal_Int32 nDeltaHeight = static_cast<sal_Int32>(rAvailableOuterRect.getHeight() - rConsumedOuterRect.getHeight());
     737 [ +  - ][ -  + ]:       1204 :     if( (aNewSize.Width + nDeltaWidth) < rAvailableOuterRect.getWidth()/3 )
     738         [ #  # ]:          0 :         nDeltaWidth = static_cast<sal_Int32>(rAvailableOuterRect.getWidth()/3 - aNewSize.Width);
     739                 :       1204 :     aNewSize.Width += nDeltaWidth;
     740                 :            : 
     741 [ +  - ][ +  + ]:       1204 :     if( (aNewSize.Height + nDeltaHeight) < rAvailableOuterRect.getHeight()/3 )
     742         [ +  - ]:         62 :         nDeltaHeight = static_cast<sal_Int32>(rAvailableOuterRect.getHeight()/3 - aNewSize.Height);
     743                 :       1204 :     aNewSize.Height += nDeltaHeight;
     744                 :            : 
     745 [ +  - ][ +  - ]:       1204 :     sal_Int32 nDiffLeft = rConsumedOuterRect.getMinX() - rAvailableOuterRect.getMinX();
     746 [ +  - ][ +  - ]:       1204 :     sal_Int32 nDiffRight = rAvailableOuterRect.getMaxX() - rConsumedOuterRect.getMaxX();
     747         [ +  + ]:       1204 :     if( nDiffLeft >= 0 )
     748                 :       1199 :         aNewPos.X -= nDiffLeft;
     749         [ +  - ]:          5 :     else if( nDiffRight >= 0 )
     750                 :            :     {
     751         [ +  - ]:          5 :         if( nDiffRight > -nDiffLeft )
     752                 :          5 :             aNewPos.X += abs(nDiffLeft);
     753         [ #  # ]:          0 :         else if( nDiffRight > abs(nDeltaWidth) )
     754                 :          0 :             aNewPos.X += nDiffRight;
     755                 :            :         else
     756                 :          0 :             aNewPos.X += abs(nDeltaWidth);
     757                 :            :     }
     758                 :            : 
     759 [ +  - ][ +  - ]:       1204 :     sal_Int32 nDiffUp = rConsumedOuterRect.getMinY() - rAvailableOuterRect.getMinY();
     760 [ +  - ][ +  - ]:       1204 :     sal_Int32 nDiffDown = rAvailableOuterRect.getMaxY() - rConsumedOuterRect.getMaxY();
     761         [ +  + ]:       1204 :     if( nDiffUp >= 0 )
     762                 :       1166 :         aNewPos.Y -= nDiffUp;
     763         [ +  + ]:         38 :     else if( nDiffDown >= 0 )
     764                 :            :     {
     765         [ +  + ]:          9 :         if( nDiffDown > -nDiffUp )
     766                 :          3 :             aNewPos.Y += abs(nDiffUp);
     767         [ -  + ]:          6 :         else if( nDiffDown > abs(nDeltaHeight) )
     768                 :          0 :             aNewPos.Y += nDiffDown;
     769                 :            :         else
     770                 :          6 :             aNewPos.Y += abs(nDeltaHeight);
     771                 :            :     }
     772                 :            : 
     773         [ +  - ]:       1204 :     return adjustPosAndSize( aNewPos, aNewSize );
     774                 :            : }
     775                 :            : 
     776                 :            : //.............................................................................
     777                 :            : } //namespace chart
     778                 :            : //.............................................................................
     779                 :            : 
     780                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10