LCOV - code coverage report
Current view: top level - chart2/source/model/main - Diagram.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 204 285 71.6 %
Date: 2012-08-25 Functions: 33 49 67.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 219 600 36.5 %

           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 "Diagram.hxx"
      21                 :            : #include "macros.hxx"
      22                 :            : #include "PropertyHelper.hxx"
      23                 :            : #include "Wall.hxx"
      24                 :            : #include "UserDefinedProperties.hxx"
      25                 :            : #include "ConfigColorScheme.hxx"
      26                 :            : #include "DiagramHelper.hxx"
      27                 :            : #include "ContainerHelper.hxx"
      28                 :            : #include "ThreeDHelper.hxx"
      29                 :            : #include "CloneHelper.hxx"
      30                 :            : #include "AxisHelper.hxx"
      31                 :            : #include "SceneProperties.hxx"
      32                 :            : #include "DisposeHelper.hxx"
      33                 :            : #include "BaseGFXHelper.hxx"
      34                 :            : #include <basegfx/numeric/ftools.hxx>
      35                 :            : #include <rtl/instance.hxx>
      36                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      37                 :            : #include <com/sun/star/chart2/RelativePosition.hpp>
      38                 :            : #include <com/sun/star/chart2/RelativeSize.hpp>
      39                 :            : #include <com/sun/star/drawing/CameraGeometry.hpp>
      40                 :            : 
      41                 :            : #include <com/sun/star/drawing/HomogenMatrix.hpp>
      42                 :            : 
      43                 :            : #include <algorithm>
      44                 :            : #include <iterator>
      45                 :            : #include <functional>
      46                 :            : 
      47                 :            : using namespace ::com::sun::star;
      48                 :            : using namespace ::com::sun::star::beans::PropertyAttribute;
      49                 :            : 
      50                 :            : using ::rtl::OUString;
      51                 :            : using ::com::sun::star::beans::Property;
      52                 :            : using ::com::sun::star::uno::Sequence;
      53                 :            : using ::com::sun::star::uno::Reference;
      54                 :            : using ::com::sun::star::uno::Any;
      55                 :            : using ::osl::MutexGuard;
      56                 :            : 
      57                 :            : // ======================================================================
      58                 :            : 
      59                 :            : namespace
      60                 :            : {
      61                 :            : 
      62                 :            : enum
      63                 :            : {
      64                 :            :     PROP_DIAGRAM_REL_POS,
      65                 :            :     PROP_DIAGRAM_REL_SIZE,
      66                 :            :     PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
      67                 :            :     PROP_DIAGRAM_SORT_BY_X_VALUES,
      68                 :            :     PROP_DIAGRAM_CONNECT_BARS,
      69                 :            :     PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
      70                 :            :     PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
      71                 :            :     PROP_DIAGRAM_STARTING_ANGLE,
      72                 :            :     PROP_DIAGRAM_RIGHT_ANGLED_AXES,
      73                 :            :     PROP_DIAGRAM_PERSPECTIVE,
      74                 :            :     PROP_DIAGRAM_ROTATION_HORIZONTAL,
      75                 :            :     PROP_DIAGRAM_ROTATION_VERTICAL,
      76                 :            :     PROP_DIAGRAM_MISSING_VALUE_TREATMENT
      77                 :            : };
      78                 :            : 
      79                 :         14 : void lcl_AddPropertiesToVector(
      80                 :            :     ::std::vector< Property > & rOutProperties )
      81                 :            : {
      82                 :            :     rOutProperties.push_back(
      83                 :            :         Property( C2U( "RelativePosition" ),
      84                 :            :                   PROP_DIAGRAM_REL_POS,
      85         [ +  - ]:         14 :                   ::getCppuType( reinterpret_cast< const chart2::RelativePosition * >(0)),
      86                 :            :                   beans::PropertyAttribute::BOUND
      87 [ +  - ][ +  - ]:         14 :                   | beans::PropertyAttribute::MAYBEVOID ));
      88                 :            : 
      89                 :            :     rOutProperties.push_back(
      90                 :            :         Property( C2U( "RelativeSize" ),
      91                 :            :                   PROP_DIAGRAM_REL_SIZE,
      92         [ +  - ]:         14 :                   ::getCppuType( reinterpret_cast< const chart2::RelativeSize * >(0)),
      93                 :            :                   beans::PropertyAttribute::BOUND
      94 [ +  - ][ +  - ]:         14 :                   | beans::PropertyAttribute::MAYBEVOID ));
      95                 :            : 
      96                 :            :     rOutProperties.push_back(
      97                 :            :         Property( C2U( "PosSizeExcludeAxes" ),
      98                 :            :                   PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
      99         [ +  - ]:         14 :                   ::getBooleanCppuType(),
     100                 :            :                   beans::PropertyAttribute::BOUND
     101 [ +  - ][ +  - ]:         14 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     102                 :            : 
     103                 :            :     rOutProperties.push_back(
     104                 :            :         Property( C2U( "SortByXValues" ),
     105                 :            :                   PROP_DIAGRAM_SORT_BY_X_VALUES,
     106         [ +  - ]:         14 :                   ::getBooleanCppuType(),
     107                 :            :                   beans::PropertyAttribute::BOUND
     108 [ +  - ][ +  - ]:         14 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     109                 :            : 
     110                 :            :     rOutProperties.push_back(
     111                 :            :         Property( C2U("ConnectBars"),
     112                 :            :                   PROP_DIAGRAM_CONNECT_BARS,
     113         [ +  - ]:         14 :                   ::getBooleanCppuType(),
     114                 :            :                   beans::PropertyAttribute::BOUND
     115 [ +  - ][ +  - ]:         14 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     116                 :            : 
     117                 :            :     rOutProperties.push_back(
     118                 :            :         Property( C2U("GroupBarsPerAxis"),
     119                 :            :                   PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
     120         [ +  - ]:         14 :                   ::getBooleanCppuType(),
     121                 :            :                   beans::PropertyAttribute::BOUND
     122 [ +  - ][ +  - ]:         14 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     123                 :            : 
     124                 :            :     rOutProperties.push_back(
     125                 :            :         Property( C2U("IncludeHiddenCells"),
     126                 :            :                   PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
     127         [ +  - ]:         14 :                   ::getBooleanCppuType(),
     128                 :            :                   beans::PropertyAttribute::BOUND
     129 [ +  - ][ +  - ]:         14 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     130                 :            : 
     131                 :            :     rOutProperties.push_back(
     132                 :            :         Property( C2U( "StartingAngle" ),
     133                 :            :                   PROP_DIAGRAM_STARTING_ANGLE,
     134         [ +  - ]:         14 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0) ),
     135                 :            :                   beans::PropertyAttribute::BOUND
     136 [ +  - ][ +  - ]:         14 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     137                 :            : 
     138                 :            :     rOutProperties.push_back(
     139                 :            :         Property( C2U("RightAngledAxes"),
     140                 :            :                   PROP_DIAGRAM_RIGHT_ANGLED_AXES,
     141         [ +  - ]:         14 :                   ::getBooleanCppuType(),
     142                 :            :                   beans::PropertyAttribute::BOUND
     143 [ +  - ][ +  - ]:         14 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     144                 :            : 
     145                 :            :     rOutProperties.push_back(
     146                 :            :         Property( C2U("Perspective"),
     147                 :            :                   PROP_DIAGRAM_PERSPECTIVE,
     148                 :         14 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     149 [ +  - ][ +  - ]:         14 :                   beans::PropertyAttribute::MAYBEVOID ));
     150                 :            : 
     151                 :            :     rOutProperties.push_back(
     152                 :            :         Property( C2U("RotationHorizontal"),
     153                 :            :                   PROP_DIAGRAM_ROTATION_HORIZONTAL,
     154                 :         14 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     155 [ +  - ][ +  - ]:         14 :                   beans::PropertyAttribute::MAYBEVOID ));
     156                 :            : 
     157                 :            :     rOutProperties.push_back(
     158                 :            :         Property( C2U("RotationVertical"),
     159                 :            :                   PROP_DIAGRAM_ROTATION_VERTICAL,
     160                 :         14 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     161 [ +  - ][ +  - ]:         14 :                   beans::PropertyAttribute::MAYBEVOID ));
     162                 :            : 
     163                 :            :     rOutProperties.push_back(
     164                 :            :         Property( C2U( "MissingValueTreatment" ),
     165                 :            :                   PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
     166         [ +  - ]:         14 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     167                 :            :                   beans::PropertyAttribute::BOUND
     168 [ +  - ][ +  - ]:         14 :                   | beans::PropertyAttribute::MAYBEVOID ));
     169                 :         14 : }
     170                 :            : 
     171                 :            : struct StaticDiagramDefaults_Initializer
     172                 :            : {
     173                 :         14 :     ::chart::tPropertyValueMap* operator()()
     174                 :            :     {
     175 [ +  - ][ +  - ]:         14 :         static ::chart::tPropertyValueMap aStaticDefaults;
         [ +  - ][ #  # ]
     176                 :         14 :         lcl_AddDefaultsToMap( aStaticDefaults );
     177                 :         14 :         return &aStaticDefaults;
     178                 :            :     }
     179                 :            : private:
     180                 :         14 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
     181                 :            :     {
     182         [ +  - ]:         14 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true );
     183         [ +  - ]:         14 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false );
     184         [ +  - ]:         14 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false );
     185         [ +  - ]:         14 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );
     186         [ +  - ]:         14 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true );
     187         [ +  - ]:         14 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false );
     188         [ +  - ]:         14 :         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
     189                 :         14 :         ::chart::SceneProperties::AddDefaultsToMap( rOutMap );
     190                 :         14 :     }
     191                 :            : };
     192                 :            : 
     193                 :            : struct StaticDiagramDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDiagramDefaults_Initializer >
     194                 :            : {
     195                 :            : };
     196                 :            : 
     197                 :            : struct StaticDiagramInfoHelper_Initializer
     198                 :            : {
     199                 :         14 :     ::cppu::OPropertyArrayHelper* operator()()
     200                 :            :     {
     201 [ +  - ][ +  - ]:         14 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
     202                 :         14 :         return &aPropHelper;
     203                 :            :     }
     204                 :            : 
     205                 :            : private:
     206                 :         14 :     Sequence< Property > lcl_GetPropertySequence()
     207                 :            :     {
     208         [ +  - ]:         14 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
     209         [ +  - ]:         14 :         lcl_AddPropertiesToVector( aProperties );
     210         [ +  - ]:         14 :         ::chart::SceneProperties::AddPropertiesToVector( aProperties );
     211         [ +  - ]:         14 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
     212                 :            : 
     213                 :            :         ::std::sort( aProperties.begin(), aProperties.end(),
     214         [ +  - ]:         14 :                      ::chart::PropertyNameLess() );
     215                 :            : 
     216         [ +  - ]:         14 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
     217                 :            :     }
     218                 :            : };
     219                 :            : 
     220                 :            : struct StaticDiagramInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDiagramInfoHelper_Initializer >
     221                 :            : {
     222                 :            : };
     223                 :            : 
     224                 :            : struct StaticDiagramInfo_Initializer
     225                 :            : {
     226                 :          0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     227                 :            :     {
     228                 :            :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     229 [ #  # ][ #  # ]:          0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDiagramInfoHelper::get() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     230                 :          0 :         return &xPropertySetInfo;
     231                 :            :     }
     232                 :            : };
     233                 :            : 
     234                 :            : struct StaticDiagramInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDiagramInfo_Initializer >
     235                 :            : {
     236                 :            : };
     237                 :            : 
     238                 :            : /// clones a UNO-sequence of UNO-References
     239                 :            : typedef Reference< chart2::XCoordinateSystem > lcl_tCooSysRef;
     240                 :            : typedef ::std::map< lcl_tCooSysRef, lcl_tCooSysRef >  lcl_tCooSysMapping;
     241                 :            : typedef ::std::vector< lcl_tCooSysRef >               lcl_tCooSysVector;
     242                 :            : 
     243                 :          0 : lcl_tCooSysMapping lcl_CloneCoordinateSystems(
     244                 :            :         const lcl_tCooSysVector & rSource,
     245                 :            :         lcl_tCooSysVector & rDestination )
     246                 :            : {
     247                 :          0 :     lcl_tCooSysMapping aResult;
     248                 :            : 
     249 [ #  # ][ #  # ]:          0 :     for( lcl_tCooSysVector::const_iterator aIt( rSource.begin());
     250                 :          0 :          aIt != rSource.end(); ++aIt )
     251                 :            :     {
     252                 :          0 :         lcl_tCooSysRef xClone;
     253                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable >
     254         [ #  # ]:          0 :               xCloneable( *aIt, ::com::sun::star::uno::UNO_QUERY );
     255         [ #  # ]:          0 :         if( xCloneable.is())
     256 [ #  # ][ #  # ]:          0 :             xClone.set( xCloneable->createClone(), ::com::sun::star::uno::UNO_QUERY );
                 [ #  # ]
     257                 :            : 
     258         [ #  # ]:          0 :         if( xClone.is())
     259                 :            :         {
     260         [ #  # ]:          0 :             rDestination.push_back( xClone );
     261 [ #  # ][ #  # ]:          0 :             aResult.insert( lcl_tCooSysMapping::value_type( *aIt, xClone ));
                 [ #  # ]
     262                 :            :         }
     263                 :            :         else
     264         [ #  # ]:          0 :             rDestination.push_back( *aIt );
     265                 :          0 :     }
     266                 :            : 
     267                 :          0 :     return aResult;
     268                 :            : }
     269                 :            : 
     270                 :            : } // anonymous namespace
     271                 :            : 
     272                 :            : // ======================================================================
     273                 :            : 
     274                 :            : namespace chart
     275                 :            : {
     276                 :            : 
     277                 :         62 : Diagram::Diagram( uno::Reference< uno::XComponentContext > const & xContext ) :
     278                 :            :         ::property::OPropertySet( m_aMutex ),
     279                 :            :         m_xContext( xContext ),
     280 [ +  - ][ +  - ]:         62 :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
         [ +  - ][ +  - ]
     281                 :            : {
     282                 :            :     // Set camera position to a default position (that should be set hard, so
     283                 :            :     // that it will be exported.  The property default is a camera looking
     284                 :            :     // straight ono the scene).  These defaults have been acquired from the old
     285                 :            :     // chart implemetation.
     286                 :            :     setFastPropertyValue_NoBroadcast(
     287                 :            :         SceneProperties::PROP_SCENE_CAMERA_GEOMETRY, uno::makeAny(
     288 [ +  - ][ +  - ]:         62 :             ThreeDHelper::getDefaultCameraGeometry()));
                 [ +  - ]
     289                 :         62 : }
     290                 :            : 
     291                 :          0 : Diagram::Diagram( const Diagram & rOther ) :
     292                 :            :         MutexContainer(),
     293                 :            :         impl::Diagram_Base(),
     294                 :            :         ::property::OPropertySet( rOther, m_aMutex ),
     295                 :            :     m_xContext( rOther.m_xContext ),
     296 [ #  # ][ #  # ]:          0 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
         [ #  # ][ #  # ]
     297                 :            : {
     298                 :            :     lcl_tCooSysMapping aCooSysMapping =
     299         [ #  # ]:          0 :         lcl_CloneCoordinateSystems( rOther.m_aCoordSystems, m_aCoordSystems );
     300         [ #  # ]:          0 :     ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems, m_xModifyEventForwarder );
     301                 :            : 
     302 [ #  # ][ #  # ]:          0 :     m_xWall.set( CloneHelper::CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xWall ));
     303 [ #  # ][ #  # ]:          0 :     m_xFloor.set( CloneHelper::CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xFloor ));
     304 [ #  # ][ #  # ]:          0 :     m_xTitle.set( CloneHelper::CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
     305 [ #  # ][ #  # ]:          0 :     m_xLegend.set( CloneHelper::CreateRefClone< Reference< chart2::XLegend > >()( rOther.m_xLegend ));
     306                 :            : 
     307         [ #  # ]:          0 :     ModifyListenerHelper::addListener( m_xWall, m_xModifyEventForwarder );
     308         [ #  # ]:          0 :     ModifyListenerHelper::addListener( m_xFloor, m_xModifyEventForwarder );
     309         [ #  # ]:          0 :     ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
     310         [ #  # ]:          0 :     ModifyListenerHelper::addListener( m_xLegend, m_xModifyEventForwarder );
     311                 :          0 : }
     312                 :            : 
     313 [ +  - ][ +  - ]:         62 : Diagram::~Diagram()
     314                 :            : {
     315                 :            :     try
     316                 :            :     {
     317         [ +  - ]:         62 :         ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems, m_xModifyEventForwarder );
     318                 :            : 
     319         [ +  - ]:         62 :         ModifyListenerHelper::removeListener( m_xWall, m_xModifyEventForwarder );
     320         [ +  - ]:         62 :         ModifyListenerHelper::removeListener( m_xFloor, m_xModifyEventForwarder );
     321         [ +  - ]:         62 :         ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
     322         [ +  - ]:         62 :         ModifyListenerHelper::removeListener( m_xLegend, m_xModifyEventForwarder );
     323                 :            :     }
     324         [ #  # ]:          0 :     catch( const uno::Exception & ex )
     325                 :            :     {
     326                 :            :         ASSERT_EXCEPTION( ex );
     327                 :            :     }
     328 [ -  + ][ #  # ]:        124 : }
     329                 :            : 
     330                 :            : // ____ XDiagram ____
     331                 :       1673 : uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
     332                 :            :     throw (uno::RuntimeException)
     333                 :            : {
     334                 :       1673 :     uno::Reference< beans::XPropertySet > xRet;
     335                 :       1673 :     bool bAddListener = false;
     336                 :            :     {
     337 [ +  - ][ +  - ]:       1673 :         MutexGuard aGuard( GetMutex() );
     338         [ +  + ]:       1673 :         if( !m_xWall.is() )
     339                 :            :         {
     340 [ +  - ][ +  - ]:         62 :             m_xWall.set( new Wall() );
                 [ +  - ]
     341                 :         62 :             bAddListener = true;
     342                 :            :         }
     343 [ +  - ][ +  - ]:       1673 :         xRet =  m_xWall;
     344                 :            :     }
     345         [ +  + ]:       1673 :     if(bAddListener)
     346         [ +  - ]:         62 :         ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
     347                 :       1673 :     return xRet;
     348                 :            : }
     349                 :            : 
     350                 :        610 : uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
     351                 :            :     throw (uno::RuntimeException)
     352                 :            : {
     353                 :        610 :     uno::Reference< beans::XPropertySet > xRet;
     354                 :        610 :     bool bAddListener = false;
     355                 :            :     {
     356 [ +  - ][ +  - ]:        610 :         MutexGuard aGuard( GetMutex() );
     357         [ +  + ]:        610 :         if( !m_xFloor.is() )
     358                 :            :         {
     359 [ +  - ][ +  - ]:         56 :             m_xFloor.set( new Wall() );
                 [ +  - ]
     360                 :         56 :             bAddListener = true;
     361                 :            :         }
     362 [ +  - ][ +  - ]:        610 :         xRet = m_xFloor;
     363                 :            :     }
     364         [ +  + ]:        610 :     if(bAddListener)
     365         [ +  - ]:         56 :         ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
     366                 :        610 :     return xRet;
     367                 :            : }
     368                 :            : 
     369                 :      10574 : uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend()
     370                 :            :     throw (uno::RuntimeException)
     371                 :            : {
     372 [ +  - ][ +  - ]:      10574 :     MutexGuard aGuard( GetMutex() );
     373         [ +  - ]:      10574 :     return m_xLegend;
     374                 :            : }
     375                 :            : 
     376                 :         62 : void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xNewLegend )
     377                 :            :     throw (uno::RuntimeException)
     378                 :            : {
     379                 :         62 :     Reference< chart2::XLegend > xOldLegend;
     380                 :            :     {
     381 [ +  - ][ +  - ]:         62 :         MutexGuard aGuard( GetMutex() );
     382 [ +  - ][ -  + ]:         62 :         if( m_xLegend == xNewLegend )
     383                 :         62 :             return;
     384         [ +  - ]:         62 :         xOldLegend = m_xLegend;
     385 [ +  - ][ +  - ]:         62 :         m_xLegend = xNewLegend;
                 [ +  - ]
     386                 :            :     }
     387         [ -  + ]:         62 :     if( xOldLegend.is())
     388         [ #  # ]:          0 :         ModifyListenerHelper::removeListener( xOldLegend, m_xModifyEventForwarder );
     389         [ +  - ]:         62 :     if( xNewLegend.is())
     390         [ +  - ]:         62 :         ModifyListenerHelper::addListener( xNewLegend, m_xModifyEventForwarder );
     391 [ +  - ][ +  - ]:         62 :     fireModifyEvent();
     392                 :            : }
     393                 :            : 
     394                 :       1330 : Reference< chart2::XColorScheme > SAL_CALL Diagram::getDefaultColorScheme()
     395                 :            :     throw (uno::RuntimeException)
     396                 :            : {
     397                 :       1330 :     Reference< chart2::XColorScheme > xRet;
     398                 :            :     {
     399 [ +  - ][ +  - ]:       1330 :         MutexGuard aGuard( GetMutex() );
     400 [ +  - ][ +  - ]:       1330 :         xRet = m_xColorScheme;
     401                 :            :     }
     402                 :            : 
     403         [ +  + ]:       1330 :     if( !xRet.is())
     404                 :            :     {
     405 [ +  - ][ +  - ]:         59 :         xRet.set( createConfigColorScheme( m_xContext ));
     406 [ +  - ][ +  - ]:         59 :         MutexGuard aGuard( GetMutex() );
     407 [ +  - ][ +  - ]:         59 :         m_xColorScheme = xRet;
     408                 :            :     }
     409                 :       1330 :     return xRet;
     410                 :            : }
     411                 :            : 
     412                 :          0 : void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorScheme >& xColorScheme )
     413                 :            :     throw (uno::RuntimeException)
     414                 :            : {
     415                 :            :     {
     416 [ #  # ][ #  # ]:          0 :         MutexGuard aGuard( GetMutex() );
     417 [ #  # ][ #  # ]:          0 :         m_xColorScheme.set( xColorScheme );
     418                 :            :     }
     419                 :          0 :     fireModifyEvent();
     420                 :          0 : }
     421                 :            : 
     422                 :         38 : void SAL_CALL Diagram::setDiagramData(
     423                 :            :     const Reference< chart2::data::XDataSource >& xDataSource,
     424                 :            :     const Sequence< beans::PropertyValue >& aArguments )
     425                 :            :         throw (uno::RuntimeException)
     426                 :            : {
     427 [ +  - ][ +  - ]:         76 :     uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( m_xContext->getServiceManager()->createInstanceWithContext(
                 [ +  - ]
     428 [ +  - ][ +  - ]:         38 :             C2U( "com.sun.star.chart2.ChartTypeManager" ), m_xContext ), uno::UNO_QUERY );
                 [ +  - ]
     429 [ +  - ][ +  - ]:         38 :     DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram( this, xChartTypeManager );
     430                 :         38 :     uno::Reference< chart2::XChartTypeTemplate > xTemplate( aTemplateAndService.first );
     431         [ -  + ]:         38 :     if( !xTemplate.is() )
     432 [ #  # ][ #  # ]:          0 :         xTemplate.set( xChartTypeManager->createInstance( C2U("com.sun.star.chart2.template.Column") ), uno::UNO_QUERY );
         [ #  # ][ #  # ]
     433         [ -  + ]:         38 :     if(!xTemplate.is())
     434                 :         38 :         return;
     435 [ +  - ][ +  - ]:         38 :     xTemplate->changeDiagramData( this, xDataSource, aArguments );
         [ +  - ][ -  + ]
         [ +  - ][ -  + ]
                 [ +  - ]
     436                 :            : }
     437                 :            : 
     438                 :            : // ____ XTitled ____
     439                 :       9443 : uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject()
     440                 :            :     throw (uno::RuntimeException)
     441                 :            : {
     442 [ +  - ][ +  - ]:       9443 :     MutexGuard aGuard( GetMutex() );
     443         [ +  - ]:       9443 :     return m_xTitle;
     444                 :            : }
     445                 :            : 
     446                 :         12 : void SAL_CALL Diagram::setTitleObject( const uno::Reference< chart2::XTitle >& xNewTitle )
     447                 :            :     throw (uno::RuntimeException)
     448                 :            : {
     449                 :         12 :     Reference< chart2::XTitle > xOldTitle;
     450                 :            :     {
     451 [ +  - ][ +  - ]:         12 :         MutexGuard aGuard( GetMutex() );
     452 [ +  - ][ -  + ]:         12 :         if( m_xTitle == xNewTitle )
     453                 :         12 :             return;
     454         [ +  - ]:         12 :         xOldTitle = m_xTitle;
     455 [ +  - ][ +  - ]:         12 :         m_xTitle = xNewTitle;
                 [ +  - ]
     456                 :            :     }
     457         [ +  + ]:         12 :     if( xOldTitle.is())
     458         [ +  - ]:          2 :         ModifyListenerHelper::removeListener( xOldTitle, m_xModifyEventForwarder );
     459         [ +  + ]:         12 :     if( xNewTitle.is())
     460         [ +  - ]:         10 :         ModifyListenerHelper::addListener( xNewTitle, m_xModifyEventForwarder );
     461 [ +  - ][ +  - ]:         12 :     fireModifyEvent();
     462                 :            : }
     463                 :            : 
     464                 :            : // ____ X3DDefaultSetter ____
     465                 :          0 : void SAL_CALL Diagram::set3DSettingsToDefault()
     466                 :            :     throw (uno::RuntimeException)
     467                 :            : {
     468         [ #  # ]:          0 :     ThreeDHelper::set3DSettingsToDefault( this );
     469                 :          0 : }
     470                 :            : 
     471                 :          0 : void SAL_CALL Diagram::setDefaultRotation()
     472                 :            :     throw (uno::RuntimeException)
     473                 :            : {
     474         [ #  # ]:          0 :     ThreeDHelper::setDefaultRotation( this );
     475                 :          0 : }
     476                 :            : 
     477                 :          0 : void SAL_CALL Diagram::setDefaultIllumination()
     478                 :            :     throw (uno::RuntimeException)
     479                 :            : {
     480         [ #  # ]:          0 :     ThreeDHelper::setDefaultIllumination( this );
     481                 :          0 : }
     482                 :            : 
     483                 :            : // ____ XCoordinateSystemContainer ____
     484                 :         18 : void SAL_CALL Diagram::addCoordinateSystem(
     485                 :            :     const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
     486                 :            :     throw (lang::IllegalArgumentException,
     487                 :            :            uno::RuntimeException)
     488                 :            : {
     489                 :            :     {
     490 [ +  - ][ +  - ]:         18 :         MutexGuard aGuard( GetMutex() );
     491 [ +  - ][ -  + ]:         36 :         if( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys )
     492         [ +  - ]:         36 :             != m_aCoordSystems.end())
     493         [ #  # ]:          0 :             throw lang::IllegalArgumentException();
     494                 :            : 
     495         [ -  + ]:         18 :         if( m_aCoordSystems.size()>=1 )
     496                 :            :         {
     497                 :            :             OSL_FAIL( "more than one coordinatesystem is not supported yet by the fileformat" );
     498                 :         18 :             return;
     499                 :            :         }
     500 [ +  - ][ +  - ]:         18 :         m_aCoordSystems.push_back( aCoordSys );
                 [ +  - ]
     501                 :            :     }
     502                 :         18 :     ModifyListenerHelper::addListener( aCoordSys, m_xModifyEventForwarder );
     503                 :         18 :     fireModifyEvent();
     504                 :            : }
     505                 :            : 
     506                 :         12 : void SAL_CALL Diagram::removeCoordinateSystem(
     507                 :            :     const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
     508                 :            :     throw (container::NoSuchElementException,
     509                 :            :            uno::RuntimeException)
     510                 :            : {
     511                 :            :     {
     512 [ +  - ][ +  - ]:         12 :         MutexGuard aGuard( GetMutex() );
     513                 :            :         ::std::vector< uno::Reference< chart2::XCoordinateSystem > >::iterator
     514         [ +  - ]:         12 :               aIt( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys ));
     515 [ +  - ][ -  + ]:         12 :         if( aIt == m_aCoordSystems.end())
     516                 :            :             throw container::NoSuchElementException(
     517                 :            :                 C2U( "The given coordinate-system is no element of the container" ),
     518 [ #  # ][ #  # ]:          0 :                 static_cast< uno::XWeak * >( this ));
                 [ #  # ]
     519 [ +  - ][ +  - ]:         12 :         m_aCoordSystems.erase( aIt );
     520                 :            :     }
     521                 :         12 :     ModifyListenerHelper::removeListener( aCoordSys, m_xModifyEventForwarder );
     522                 :         12 :     fireModifyEvent();
     523                 :         12 : }
     524                 :            : 
     525                 :     142023 : uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > SAL_CALL Diagram::getCoordinateSystems()
     526                 :            :     throw (uno::RuntimeException)
     527                 :            : {
     528 [ +  - ][ +  - ]:     142023 :     MutexGuard aGuard( GetMutex() );
     529 [ +  - ][ +  - ]:     142023 :     return ContainerHelper::ContainerToSequence( m_aCoordSystems );
     530                 :            : }
     531                 :            : 
     532                 :         60 : void SAL_CALL Diagram::setCoordinateSystems(
     533                 :            :     const Sequence< Reference< chart2::XCoordinateSystem > >& aCoordinateSystems )
     534                 :            :     throw (lang::IllegalArgumentException,
     535                 :            :            uno::RuntimeException)
     536                 :            : {
     537         [ +  - ]:         60 :     tCoordinateSystemContainerType aNew;
     538         [ +  - ]:         60 :     tCoordinateSystemContainerType aOld;
     539         [ +  - ]:         60 :     if( aCoordinateSystems.getLength()>0 )
     540                 :            :     {
     541                 :            :         OSL_ENSURE( aCoordinateSystems.getLength()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
     542         [ +  - ]:         60 :         aNew.push_back( aCoordinateSystems[0] );
     543                 :            :     }
     544                 :            :     {
     545 [ +  - ][ +  - ]:         60 :         MutexGuard aGuard( GetMutex() );
     546                 :         60 :         std::swap( aOld, m_aCoordSystems );
     547 [ +  - ][ +  - ]:         60 :         m_aCoordSystems = aNew;
     548                 :            :     }
     549         [ +  - ]:         60 :     ModifyListenerHelper::removeListenerFromAllElements( aOld, m_xModifyEventForwarder );
     550         [ +  - ]:         60 :     ModifyListenerHelper::addListenerToAllElements( aNew, m_xModifyEventForwarder );
     551         [ +  - ]:         60 :     fireModifyEvent();
     552                 :         60 : }
     553                 :            : 
     554                 :            : // ____ XCloneable ____
     555                 :          0 : Reference< util::XCloneable > SAL_CALL Diagram::createClone()
     556                 :            :     throw (uno::RuntimeException)
     557                 :            : {
     558 [ #  # ][ #  # ]:          0 :     MutexGuard aGuard( GetMutex() );
     559 [ #  # ][ #  # ]:          0 :     return Reference< util::XCloneable >( new Diagram( *this ));
         [ #  # ][ #  # ]
     560                 :            : }
     561                 :            : 
     562                 :            : // ____ XModifyBroadcaster ____
     563                 :         62 : void SAL_CALL Diagram::addModifyListener( const Reference< util::XModifyListener >& aListener )
     564                 :            :     throw (uno::RuntimeException)
     565                 :            : {
     566                 :            :     try
     567                 :            :     {
     568         [ +  - ]:         62 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     569 [ +  - ][ +  - ]:         62 :         xBroadcaster->addModifyListener( aListener );
                 [ #  # ]
     570                 :            :     }
     571                 :          0 :     catch( const uno::Exception & ex )
     572                 :            :     {
     573                 :            :         ASSERT_EXCEPTION( ex );
     574                 :            :     }
     575                 :         62 : }
     576                 :            : 
     577                 :         62 : void SAL_CALL Diagram::removeModifyListener( const Reference< util::XModifyListener >& aListener )
     578                 :            :     throw (uno::RuntimeException)
     579                 :            : {
     580                 :            :     try
     581                 :            :     {
     582         [ +  - ]:         62 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     583 [ +  - ][ +  - ]:         62 :         xBroadcaster->removeModifyListener( aListener );
                 [ #  # ]
     584                 :            :     }
     585                 :          0 :     catch( const uno::Exception & ex )
     586                 :            :     {
     587                 :            :         ASSERT_EXCEPTION( ex );
     588                 :            :     }
     589                 :         62 : }
     590                 :            : 
     591                 :            : // ____ XModifyListener ____
     592                 :          0 : void SAL_CALL Diagram::modified( const lang::EventObject& aEvent )
     593                 :            :     throw (uno::RuntimeException)
     594                 :            : {
     595                 :          0 :     m_xModifyEventForwarder->modified( aEvent );
     596                 :          0 : }
     597                 :            : 
     598                 :            : // ____ XEventListener (base of XModifyListener) ____
     599                 :          0 : void SAL_CALL Diagram::disposing( const lang::EventObject& /* Source */ )
     600                 :            :     throw (uno::RuntimeException)
     601                 :            : {
     602                 :            :     // nothing
     603                 :          0 : }
     604                 :            : 
     605                 :            : // ____ OPropertySet ____
     606                 :        613 : void Diagram::firePropertyChangeEvent()
     607                 :            : {
     608                 :        613 :     fireModifyEvent();
     609                 :        613 : }
     610                 :            : 
     611                 :        777 : void Diagram::fireModifyEvent()
     612                 :            : {
     613 [ +  - ][ +  - ]:        777 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
                 [ +  - ]
     614                 :        777 : }
     615                 :            : 
     616                 :            : // ============================================================
     617                 :            : 
     618                 :         14 : Sequence< OUString > Diagram::getSupportedServiceNames_Static()
     619                 :            : {
     620                 :         14 :     Sequence< OUString > aServices( 3 );
     621                 :            : 
     622 [ +  - ][ +  - ]:         14 :     aServices[ 0 ] = C2U( "com.sun.star.chart2.Diagram" );
     623 [ +  - ][ +  - ]:         14 :     aServices[ 1 ] = C2U( "com.sun.star.layout.LayoutElement" );
     624 [ +  - ][ +  - ]:         14 :     aServices[ 2 ] = C2U( "com.sun.star.beans.PropertySet" );
     625                 :         14 :     return aServices;
     626                 :            : }
     627                 :            : 
     628                 :            : // ____ OPropertySet ____
     629                 :      11839 : uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const
     630                 :            :     throw(beans::UnknownPropertyException)
     631                 :            : {
     632         [ +  - ]:      11839 :     const tPropertyValueMap& rStaticDefaults = *StaticDiagramDefaults::get();
     633         [ +  - ]:      11839 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     634         [ +  + ]:      11839 :     if( aFound == rStaticDefaults.end() )
     635                 :       3441 :         return uno::Any();
     636                 :      11839 :     return (*aFound).second;
     637                 :            : }
     638                 :            : 
     639                 :            : // ____ OPropertySet ____
     640                 :      33665 : ::cppu::IPropertyArrayHelper & SAL_CALL Diagram::getInfoHelper()
     641                 :            : {
     642                 :      33665 :     return *StaticDiagramInfoHelper::get();
     643                 :            : }
     644                 :            : 
     645                 :            : // ____ XPropertySet ____
     646                 :          0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL Diagram::getPropertySetInfo()
     647                 :            :     throw (uno::RuntimeException)
     648                 :            : {
     649                 :          0 :     return *StaticDiagramInfo::get();
     650                 :            : }
     651                 :            : 
     652                 :            : // ____ XFastPropertySet ____
     653                 :        613 : void SAL_CALL Diagram::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue )
     654                 :            :     throw(beans::UnknownPropertyException,
     655                 :            :           beans::PropertyVetoException,
     656                 :            :           lang::IllegalArgumentException,
     657                 :            :           lang::WrappedTargetException, uno::RuntimeException)
     658                 :            : {
     659                 :            :     //special treatment for some 3D properties
     660         [ -  + ]:        613 :     if( PROP_DIAGRAM_PERSPECTIVE == nHandle )
     661                 :            :     {
     662                 :          0 :         sal_Int32 fPerspective = 20;
     663         [ #  # ]:          0 :         if( rValue >>=fPerspective )
     664 [ #  # ][ #  # ]:          0 :             ThreeDHelper::setCameraDistance( this, ThreeDHelper::PerspectiveToCameraDistance( fPerspective ) );
                 [ #  # ]
     665                 :            :     }
     666 [ +  - ][ -  + ]:        613 :     else if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle
     667                 :            :         || PROP_DIAGRAM_ROTATION_VERTICAL == nHandle )
     668                 :            :     {
     669                 :          0 :         sal_Int32 nNewAngleDegree = 0;
     670         [ #  # ]:          0 :         if( rValue >>=nNewAngleDegree )
     671                 :            :         {
     672                 :            :             sal_Int32 nHorizontal, nVertical;
     673 [ #  # ][ #  # ]:          0 :             ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
     674         [ #  # ]:          0 :             if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle )
     675                 :          0 :                 nHorizontal = nNewAngleDegree;
     676                 :            :             else
     677                 :          0 :                 nVertical = nNewAngleDegree;
     678 [ #  # ][ #  # ]:          0 :             ThreeDHelper::setRotationToDiagram( this, nHorizontal, nVertical );
     679                 :          0 :         }
     680                 :            :     }
     681                 :            :     else
     682                 :        613 :         ::property::OPropertySet::setFastPropertyValue( nHandle, rValue );
     683                 :        613 : }
     684                 :            : 
     685                 :      16567 : void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     686                 :            : {
     687                 :            :     //special treatment for some 3D properties
     688         [ -  + ]:      16567 :     if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
     689                 :            :     {
     690                 :            :         sal_Int32 nPerspective = ::basegfx::fround( ThreeDHelper::CameraDistanceToPerspective(
     691 [ #  # ][ #  # ]:          0 :             ThreeDHelper::getCameraDistance( const_cast< Diagram* >( this ) ) ) );
                 [ #  # ]
     692         [ #  # ]:          0 :         rValue = uno::makeAny(nPerspective);
     693                 :            :     }
     694 [ +  - ][ -  + ]:      16567 :     else if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle
     695                 :            :         || PROP_DIAGRAM_ROTATION_VERTICAL == nHandle )
     696                 :            :     {
     697                 :            :         sal_Int32 nHorizontal, nVertical;
     698 [ #  # ][ #  # ]:          0 :         ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
     699                 :          0 :         sal_Int32 nAngleDegree = 0;
     700         [ #  # ]:          0 :         if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle )
     701                 :          0 :             nAngleDegree = nHorizontal;
     702                 :            :         else
     703                 :          0 :             nAngleDegree = nVertical;
     704         [ #  # ]:          0 :         rValue = uno::makeAny(nAngleDegree);
     705                 :            :     }
     706                 :            :     else
     707                 :      16567 :         ::property::OPropertySet::getFastPropertyValue( rValue,nHandle );
     708                 :      16567 : }
     709                 :            : 
     710                 :            : // ================================================================================
     711                 :            : 
     712                 :            : using impl::Diagram_Base;
     713                 :            : 
     714 [ +  + ][ +  - ]:     892487 : IMPLEMENT_FORWARD_XINTERFACE2( Diagram, Diagram_Base, ::property::OPropertySet )
     715 [ #  # ][ #  # ]:          0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( Diagram, Diagram_Base, ::property::OPropertySet )
                 [ #  # ]
     716                 :            : 
     717                 :            : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     718 [ #  # ][ #  # ]:        173 : APPHELPER_XSERVICEINFO_IMPL( Diagram,
         [ #  # ][ #  # ]
                 [ #  # ]
     719                 :            :                              C2U( "com.sun.star.comp.chart2.Diagram" ));
     720                 :            : 
     721                 :            : } //  namespace chart
     722                 :            : 
     723                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10