LCOV - code coverage report
Current view: top level - chart2/source/model/main - Diagram.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 301 0.0 %
Date: 2014-04-14 Functions: 0 49 0.0 %
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           0 : void lcl_AddPropertiesToVector(
      84             :     ::std::vector< Property > & rOutProperties )
      85             : {
      86             :     rOutProperties.push_back(
      87             :         Property( "RelativePosition",
      88             :                   PROP_DIAGRAM_REL_POS,
      89           0 :                   ::getCppuType( reinterpret_cast< const chart2::RelativePosition * >(0)),
      90             :                   beans::PropertyAttribute::BOUND
      91           0 :                   | beans::PropertyAttribute::MAYBEVOID ));
      92             : 
      93             :     rOutProperties.push_back(
      94             :         Property( "RelativeSize",
      95             :                   PROP_DIAGRAM_REL_SIZE,
      96           0 :                   ::getCppuType( reinterpret_cast< const chart2::RelativeSize * >(0)),
      97             :                   beans::PropertyAttribute::BOUND
      98           0 :                   | beans::PropertyAttribute::MAYBEVOID ));
      99             : 
     100             :     rOutProperties.push_back(
     101             :         Property( "PosSizeExcludeAxes",
     102             :                   PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
     103           0 :                   ::getBooleanCppuType(),
     104             :                   beans::PropertyAttribute::BOUND
     105           0 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     106             : 
     107             :     rOutProperties.push_back(
     108             :         Property( CHART_UNONAME_SORT_BY_XVALUES,
     109             :                   PROP_DIAGRAM_SORT_BY_X_VALUES,
     110           0 :                   ::getBooleanCppuType(),
     111             :                   beans::PropertyAttribute::BOUND
     112           0 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     113             : 
     114             :     rOutProperties.push_back(
     115             :         Property( "ConnectBars",
     116             :                   PROP_DIAGRAM_CONNECT_BARS,
     117           0 :                   ::getBooleanCppuType(),
     118             :                   beans::PropertyAttribute::BOUND
     119           0 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     120             : 
     121             :     rOutProperties.push_back(
     122             :         Property( "GroupBarsPerAxis",
     123             :                   PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
     124           0 :                   ::getBooleanCppuType(),
     125             :                   beans::PropertyAttribute::BOUND
     126           0 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     127             : 
     128             :     rOutProperties.push_back(
     129             :         Property( "IncludeHiddenCells",
     130             :                   PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
     131           0 :                   ::getBooleanCppuType(),
     132             :                   beans::PropertyAttribute::BOUND
     133           0 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     134             : 
     135             :     rOutProperties.push_back(
     136             :         Property( "StartingAngle",
     137             :                   PROP_DIAGRAM_STARTING_ANGLE,
     138           0 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0) ),
     139             :                   beans::PropertyAttribute::BOUND
     140           0 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     141             : 
     142             :     rOutProperties.push_back(
     143             :         Property( "RightAngledAxes",
     144             :                   PROP_DIAGRAM_RIGHT_ANGLED_AXES,
     145           0 :                   ::getBooleanCppuType(),
     146             :                   beans::PropertyAttribute::BOUND
     147           0 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     148             : 
     149             :     rOutProperties.push_back(
     150             :         Property( "Perspective",
     151             :                   PROP_DIAGRAM_PERSPECTIVE,
     152           0 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     153           0 :                   beans::PropertyAttribute::MAYBEVOID ));
     154             : 
     155             :     rOutProperties.push_back(
     156             :         Property( "RotationHorizontal",
     157             :                   PROP_DIAGRAM_ROTATION_HORIZONTAL,
     158           0 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     159           0 :                   beans::PropertyAttribute::MAYBEVOID ));
     160             : 
     161             :     rOutProperties.push_back(
     162             :         Property( "RotationVertical",
     163             :                   PROP_DIAGRAM_ROTATION_VERTICAL,
     164           0 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     165           0 :                   beans::PropertyAttribute::MAYBEVOID ));
     166             : 
     167             :     rOutProperties.push_back(
     168             :         Property( "MissingValueTreatment",
     169             :                   PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
     170           0 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     171             :                   beans::PropertyAttribute::BOUND
     172           0 :                   | beans::PropertyAttribute::MAYBEVOID ));
     173             :    rOutProperties.push_back(
     174             :         Property( "3DRelativeHeight",
     175             :                   PROP_DIAGRAM_3DRELATIVEHEIGHT,
     176           0 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     177           0 :                   beans::PropertyAttribute::MAYBEVOID ));
     178             :    rOutProperties.push_back(
     179             :        Property( "DataTableHBorder",
     180             :                PROP_DIAGRAM_DATATABLEHBORDER,
     181           0 :                  ::getBooleanCppuType(),
     182             :                  beans::PropertyAttribute::BOUND
     183           0 :                  | beans::PropertyAttribute::MAYBEDEFAULT ));
     184             :    rOutProperties.push_back(
     185             :        Property( "DataTableVBorder",
     186             :                PROP_DIAGRAM_DATATABLEVBORDER,
     187           0 :                  ::getBooleanCppuType(),
     188             :                  beans::PropertyAttribute::BOUND
     189           0 :                  | beans::PropertyAttribute::MAYBEDEFAULT ));
     190             :    rOutProperties.push_back(
     191             :        Property( "DataTableOutline",
     192             :                PROP_DIAGRAM_DATATABLEOUTLINE,
     193           0 :                  ::getBooleanCppuType(),
     194             :                  beans::PropertyAttribute::BOUND
     195           0 :                  | beans::PropertyAttribute::MAYBEDEFAULT ));
     196             :    rOutProperties.push_back(
     197             :         Property( "ExternalData",
     198             :                   PROP_DIAGRAM_EXTERNALDATA,
     199           0 :                   ::getCppuType( reinterpret_cast< const OUString   * >(0)),
     200           0 :                   beans::PropertyAttribute::MAYBEVOID ));
     201           0 : }
     202             : 
     203             : struct StaticDiagramDefaults_Initializer
     204             : {
     205           0 :     ::chart::tPropertyValueMap* operator()()
     206             :     {
     207           0 :         static ::chart::tPropertyValueMap aStaticDefaults;
     208           0 :         lcl_AddDefaultsToMap( aStaticDefaults );
     209           0 :         return &aStaticDefaults;
     210             :     }
     211             : private:
     212           0 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
     213             :     {
     214           0 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true );
     215           0 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false );
     216           0 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false );
     217           0 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );
     218           0 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true );
     219           0 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false );
     220           0 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEHBORDER, false );
     221           0 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEVBORDER, false );
     222           0 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEOUTLINE, false );
     223           0 :         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
     224           0 :         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 );
     225           0 :          ::chart::SceneProperties::AddDefaultsToMap( rOutMap );
     226           0 :     }
     227             : };
     228             : 
     229             : struct StaticDiagramDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDiagramDefaults_Initializer >
     230             : {
     231             : };
     232             : 
     233             : struct StaticDiagramInfoHelper_Initializer
     234             : {
     235           0 :     ::cppu::OPropertyArrayHelper* operator()()
     236             :     {
     237           0 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
     238           0 :         return &aPropHelper;
     239             :     }
     240             : 
     241             : private:
     242           0 :     Sequence< Property > lcl_GetPropertySequence()
     243             :     {
     244           0 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
     245           0 :         lcl_AddPropertiesToVector( aProperties );
     246           0 :         ::chart::SceneProperties::AddPropertiesToVector( aProperties );
     247           0 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
     248             : 
     249             :         ::std::sort( aProperties.begin(), aProperties.end(),
     250           0 :                      ::chart::PropertyNameLess() );
     251             : 
     252           0 :         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           0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     263             :     {
     264             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     265           0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDiagramInfoHelper::get() ) );
     266           0 :         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           0 : Diagram::Diagram( uno::Reference< uno::XComponentContext > const & xContext ) :
     312             :         ::property::OPropertySet( m_aMutex ),
     313             :         m_xContext( xContext ),
     314           0 :         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           0 :             ThreeDHelper::getDefaultCameraGeometry()));
     323           0 : }
     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           0 : Diagram::~Diagram()
     348             : {
     349             :     try
     350             :     {
     351           0 :         ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems, m_xModifyEventForwarder );
     352             : 
     353           0 :         ModifyListenerHelper::removeListener( m_xWall, m_xModifyEventForwarder );
     354           0 :         ModifyListenerHelper::removeListener( m_xFloor, m_xModifyEventForwarder );
     355           0 :         ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
     356           0 :         ModifyListenerHelper::removeListener( m_xLegend, m_xModifyEventForwarder );
     357             :     }
     358           0 :     catch( const uno::Exception & ex )
     359             :     {
     360             :         ASSERT_EXCEPTION( ex );
     361             :     }
     362           0 : }
     363             : 
     364             : // ____ XDiagram ____
     365           0 : uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
     366             :     throw (uno::RuntimeException, std::exception)
     367             : {
     368           0 :     uno::Reference< beans::XPropertySet > xRet;
     369           0 :     bool bAddListener = false;
     370             :     {
     371           0 :         MutexGuard aGuard( GetMutex() );
     372           0 :         if( !m_xWall.is() )
     373             :         {
     374           0 :             m_xWall.set( new Wall() );
     375           0 :             bAddListener = true;
     376             :         }
     377           0 :         xRet =  m_xWall;
     378             :     }
     379           0 :     if(bAddListener)
     380           0 :         ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
     381           0 :     return xRet;
     382             : }
     383             : 
     384           0 : uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
     385             :     throw (uno::RuntimeException, std::exception)
     386             : {
     387           0 :     uno::Reference< beans::XPropertySet > xRet;
     388           0 :     bool bAddListener = false;
     389             :     {
     390           0 :         MutexGuard aGuard( GetMutex() );
     391           0 :         if( !m_xFloor.is() )
     392             :         {
     393           0 :             m_xFloor.set( new Wall() );
     394           0 :             bAddListener = true;
     395             :         }
     396           0 :         xRet = m_xFloor;
     397             :     }
     398           0 :     if(bAddListener)
     399           0 :         ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
     400           0 :     return xRet;
     401             : }
     402             : 
     403           0 : uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend()
     404             :     throw (uno::RuntimeException, std::exception)
     405             : {
     406           0 :     MutexGuard aGuard( GetMutex() );
     407           0 :     return m_xLegend;
     408             : }
     409             : 
     410           0 : void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xNewLegend )
     411             :     throw (uno::RuntimeException, std::exception)
     412             : {
     413           0 :     Reference< chart2::XLegend > xOldLegend;
     414             :     {
     415           0 :         MutexGuard aGuard( GetMutex() );
     416           0 :         if( m_xLegend == xNewLegend )
     417           0 :             return;
     418           0 :         xOldLegend = m_xLegend;
     419           0 :         m_xLegend = xNewLegend;
     420             :     }
     421           0 :     if( xOldLegend.is())
     422           0 :         ModifyListenerHelper::removeListener( xOldLegend, m_xModifyEventForwarder );
     423           0 :     if( xNewLegend.is())
     424           0 :         ModifyListenerHelper::addListener( xNewLegend, m_xModifyEventForwarder );
     425           0 :     fireModifyEvent();
     426             : }
     427             : 
     428           0 : Reference< chart2::XColorScheme > SAL_CALL Diagram::getDefaultColorScheme()
     429             :     throw (uno::RuntimeException, std::exception)
     430             : {
     431           0 :     Reference< chart2::XColorScheme > xRet;
     432             :     {
     433           0 :         MutexGuard aGuard( GetMutex() );
     434           0 :         xRet = m_xColorScheme;
     435             :     }
     436             : 
     437           0 :     if( !xRet.is())
     438             :     {
     439           0 :         xRet.set( createConfigColorScheme( m_xContext ));
     440           0 :         MutexGuard aGuard( GetMutex() );
     441           0 :         m_xColorScheme = xRet;
     442             :     }
     443           0 :     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           0 : 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           0 :     uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( m_xContext->getServiceManager()->createInstanceWithContext(
     462           0 :             "com.sun.star.chart2.ChartTypeManager", m_xContext ), uno::UNO_QUERY );
     463           0 :     DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram( this, xChartTypeManager );
     464           0 :     uno::Reference< chart2::XChartTypeTemplate > xTemplate( aTemplateAndService.first );
     465           0 :     if( !xTemplate.is() )
     466           0 :         xTemplate.set( xChartTypeManager->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY );
     467           0 :     if(!xTemplate.is())
     468           0 :         return;
     469           0 :     xTemplate->changeDiagramData( this, xDataSource, aArguments );
     470             : }
     471             : 
     472             : // ____ XTitled ____
     473           0 : uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject()
     474             :     throw (uno::RuntimeException, std::exception)
     475             : {
     476           0 :     MutexGuard aGuard( GetMutex() );
     477           0 :     return m_xTitle;
     478             : }
     479             : 
     480           0 : void SAL_CALL Diagram::setTitleObject( const uno::Reference< chart2::XTitle >& xNewTitle )
     481             :     throw (uno::RuntimeException, std::exception)
     482             : {
     483           0 :     Reference< chart2::XTitle > xOldTitle;
     484             :     {
     485           0 :         MutexGuard aGuard( GetMutex() );
     486           0 :         if( m_xTitle == xNewTitle )
     487           0 :             return;
     488           0 :         xOldTitle = m_xTitle;
     489           0 :         m_xTitle = xNewTitle;
     490             :     }
     491           0 :     if( xOldTitle.is())
     492           0 :         ModifyListenerHelper::removeListener( xOldTitle, m_xModifyEventForwarder );
     493           0 :     if( xNewTitle.is())
     494           0 :         ModifyListenerHelper::addListener( xNewTitle, m_xModifyEventForwarder );
     495           0 :     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           0 : void SAL_CALL Diagram::addCoordinateSystem(
     519             :     const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
     520             :     throw (lang::IllegalArgumentException,
     521             :            uno::RuntimeException, std::exception)
     522             : {
     523             :     {
     524           0 :         MutexGuard aGuard( GetMutex() );
     525           0 :         if( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys )
     526           0 :             != m_aCoordSystems.end())
     527           0 :             throw lang::IllegalArgumentException();
     528             : 
     529           0 :         if( m_aCoordSystems.size()>=1 )
     530             :         {
     531             :             OSL_FAIL( "more than one coordinatesystem is not supported yet by the fileformat" );
     532           0 :             return;
     533             :         }
     534           0 :         m_aCoordSystems.push_back( aCoordSys );
     535             :     }
     536           0 :     ModifyListenerHelper::addListener( aCoordSys, m_xModifyEventForwarder );
     537           0 :     fireModifyEvent();
     538             : }
     539             : 
     540           0 : void SAL_CALL Diagram::removeCoordinateSystem(
     541             :     const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
     542             :     throw (container::NoSuchElementException,
     543             :            uno::RuntimeException, std::exception)
     544             : {
     545             :     {
     546           0 :         MutexGuard aGuard( GetMutex() );
     547             :         ::std::vector< uno::Reference< chart2::XCoordinateSystem > >::iterator
     548           0 :               aIt( ::std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys ));
     549           0 :         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           0 :         m_aCoordSystems.erase( aIt );
     554             :     }
     555           0 :     ModifyListenerHelper::removeListener( aCoordSys, m_xModifyEventForwarder );
     556           0 :     fireModifyEvent();
     557           0 : }
     558             : 
     559           0 : uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > SAL_CALL Diagram::getCoordinateSystems()
     560             :     throw (uno::RuntimeException, std::exception)
     561             : {
     562           0 :     MutexGuard aGuard( GetMutex() );
     563           0 :     return ContainerHelper::ContainerToSequence( m_aCoordSystems );
     564             : }
     565             : 
     566           0 : void SAL_CALL Diagram::setCoordinateSystems(
     567             :     const Sequence< Reference< chart2::XCoordinateSystem > >& aCoordinateSystems )
     568             :     throw (lang::IllegalArgumentException,
     569             :            uno::RuntimeException, std::exception)
     570             : {
     571           0 :     tCoordinateSystemContainerType aNew;
     572           0 :     tCoordinateSystemContainerType aOld;
     573           0 :     if( aCoordinateSystems.getLength()>0 )
     574             :     {
     575             :         OSL_ENSURE( aCoordinateSystems.getLength()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
     576           0 :         aNew.push_back( aCoordinateSystems[0] );
     577             :     }
     578             :     {
     579           0 :         MutexGuard aGuard( GetMutex() );
     580           0 :         std::swap( aOld, m_aCoordSystems );
     581           0 :         m_aCoordSystems = aNew;
     582             :     }
     583           0 :     ModifyListenerHelper::removeListenerFromAllElements( aOld, m_xModifyEventForwarder );
     584           0 :     ModifyListenerHelper::addListenerToAllElements( aNew, m_xModifyEventForwarder );
     585           0 :     fireModifyEvent();
     586           0 : }
     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           0 : void SAL_CALL Diagram::addModifyListener( const Reference< util::XModifyListener >& aListener )
     598             :     throw (uno::RuntimeException, std::exception)
     599             : {
     600             :     try
     601             :     {
     602           0 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     603           0 :         xBroadcaster->addModifyListener( aListener );
     604             :     }
     605           0 :     catch( const uno::Exception & ex )
     606             :     {
     607             :         ASSERT_EXCEPTION( ex );
     608             :     }
     609           0 : }
     610             : 
     611           0 : void SAL_CALL Diagram::removeModifyListener( const Reference< util::XModifyListener >& aListener )
     612             :     throw (uno::RuntimeException, std::exception)
     613             : {
     614             :     try
     615             :     {
     616           0 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     617           0 :         xBroadcaster->removeModifyListener( aListener );
     618             :     }
     619           0 :     catch( const uno::Exception & ex )
     620             :     {
     621             :         ASSERT_EXCEPTION( ex );
     622             :     }
     623           0 : }
     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           0 : void Diagram::firePropertyChangeEvent()
     641             : {
     642           0 :     fireModifyEvent();
     643           0 : }
     644             : 
     645           0 : void Diagram::fireModifyEvent()
     646             : {
     647           0 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
     648           0 : }
     649             : 
     650           0 : Sequence< OUString > Diagram::getSupportedServiceNames_Static()
     651             : {
     652           0 :     Sequence< OUString > aServices( 3 );
     653             : 
     654           0 :     aServices[ 0 ] = "com.sun.star.chart2.Diagram";
     655           0 :     aServices[ 1 ] = "com.sun.star.layout.LayoutElement";
     656           0 :     aServices[ 2 ] = "com.sun.star.beans.PropertySet";
     657           0 :     return aServices;
     658             : }
     659             : 
     660             : // ____ OPropertySet ____
     661           0 : uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const
     662             :     throw(beans::UnknownPropertyException)
     663             : {
     664           0 :     const tPropertyValueMap& rStaticDefaults = *StaticDiagramDefaults::get();
     665           0 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     666           0 :     if( aFound == rStaticDefaults.end() )
     667           0 :         return uno::Any();
     668           0 :     return (*aFound).second;
     669             : }
     670             : 
     671             : // ____ OPropertySet ____
     672           0 : ::cppu::IPropertyArrayHelper & SAL_CALL Diagram::getInfoHelper()
     673             : {
     674           0 :     return *StaticDiagramInfoHelper::get();
     675             : }
     676             : 
     677             : // ____ XPropertySet ____
     678           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL Diagram::getPropertySetInfo()
     679             :     throw (uno::RuntimeException, std::exception)
     680             : {
     681           0 :     return *StaticDiagramInfo::get();
     682             : }
     683             : 
     684             : // ____ XFastPropertySet ____
     685           0 : 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           0 :     if( PROP_DIAGRAM_PERSPECTIVE == nHandle )
     693             :     {
     694           0 :         sal_Int32 fPerspective = 20;
     695           0 :         if( rValue >>=fPerspective )
     696           0 :             ThreeDHelper::setCameraDistance( this, ThreeDHelper::PerspectiveToCameraDistance( fPerspective ) );
     697             :     }
     698           0 :     else if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle
     699           0 :         || PROP_DIAGRAM_ROTATION_VERTICAL == nHandle )
     700             :     {
     701           0 :         sal_Int32 nNewAngleDegree = 0;
     702           0 :         if( rValue >>=nNewAngleDegree )
     703             :         {
     704             :             sal_Int32 nHorizontal, nVertical;
     705           0 :             ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
     706           0 :             if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle )
     707           0 :                 nHorizontal = nNewAngleDegree;
     708             :             else
     709           0 :                 nVertical = nNewAngleDegree;
     710           0 :             ThreeDHelper::setRotationToDiagram( this, nHorizontal, nVertical );
     711           0 :         }
     712             :     }
     713             :     else
     714           0 :         ::property::OPropertySet::setFastPropertyValue( nHandle, rValue );
     715           0 : }
     716             : 
     717           0 : void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     718             : {
     719             :     //special treatment for some 3D properties
     720           0 :     if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
     721             :     {
     722             :         sal_Int32 nPerspective = ::basegfx::fround( ThreeDHelper::CameraDistanceToPerspective(
     723           0 :             ThreeDHelper::getCameraDistance( const_cast< Diagram* >( this ) ) ) );
     724           0 :         rValue = uno::makeAny(nPerspective);
     725             :     }
     726           0 :     else if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle
     727           0 :         || PROP_DIAGRAM_ROTATION_VERTICAL == nHandle )
     728             :     {
     729             :         sal_Int32 nHorizontal, nVertical;
     730           0 :         ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
     731           0 :         sal_Int32 nAngleDegree = 0;
     732           0 :         if( PROP_DIAGRAM_ROTATION_HORIZONTAL == nHandle )
     733           0 :             nAngleDegree = nHorizontal;
     734             :         else
     735           0 :             nAngleDegree = nVertical;
     736           0 :         rValue = uno::makeAny(nAngleDegree);
     737             :     }
     738             :     else
     739           0 :         ::property::OPropertySet::getFastPropertyValue( rValue,nHandle );
     740           0 : }
     741             : 
     742             : using impl::Diagram_Base;
     743             : 
     744           0 : 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           0 : APPHELPER_XSERVICEINFO_IMPL( Diagram,
     749             :                              OUString("com.sun.star.comp.chart2.Diagram") );
     750             : 
     751             : } //  namespace chart
     752             : 
     753             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10