LCOV - code coverage report
Current view: top level - chart2/source/model/main - Diagram.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 245 302 81.1 %
Date: 2014-11-03 Functions: 37 51 72.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10