LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/model/main - Axis.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 171 250 68.4 %
Date: 2012-12-17 Functions: 27 42 64.3 %
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 "Axis.hxx"
      21             : #include "GridProperties.hxx"
      22             : #include "macros.hxx"
      23             : #include "CharacterProperties.hxx"
      24             : #include "LineProperties.hxx"
      25             : #include "UserDefinedProperties.hxx"
      26             : #include "PropertyHelper.hxx"
      27             : #include "ContainerHelper.hxx"
      28             : #include "CloneHelper.hxx"
      29             : #include "AxisHelper.hxx"
      30             : #include "EventListenerHelper.hxx"
      31             : #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
      32             : #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
      33             : #include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
      34             : #include <com/sun/star/chart/ChartAxisPosition.hpp>
      35             : #include <com/sun/star/chart2/AxisType.hpp>
      36             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      37             : #include <com/sun/star/lang/Locale.hpp>
      38             : #include <com/sun/star/drawing/LineStyle.hpp>
      39             : #include <com/sun/star/drawing/LineDash.hpp>
      40             : #include <com/sun/star/drawing/LineJoint.hpp>
      41             : #include <com/sun/star/awt/Size.hpp>
      42             : #include <rtl/uuid.h>
      43             : #include <cppuhelper/queryinterface.hxx>
      44             : 
      45             : #include <vector>
      46             : #include <algorithm>
      47             : 
      48             : using namespace ::com::sun::star;
      49             : using namespace ::com::sun::star::beans::PropertyAttribute;
      50             : 
      51             : using ::rtl::OUString;
      52             : using ::com::sun::star::uno::Sequence;
      53             : using ::com::sun::star::uno::Reference;
      54             : using ::com::sun::star::uno::Any;
      55             : using ::com::sun::star::beans::Property;
      56             : using ::osl::MutexGuard;
      57             : 
      58             : namespace
      59             : {
      60             : 
      61           2 : static const OUString lcl_aServiceName(
      62             :     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.Axis" ));
      63             : 
      64             : enum
      65             : {
      66             :     PROP_AXIS_SHOW,
      67             :     PROP_AXIS_CROSSOVER_POSITION,
      68             :     PROP_AXIS_CROSSOVER_VALUE,
      69             :     PROP_AXIS_DISPLAY_LABELS,
      70             :     PROP_AXIS_NUMBER_FORMAT,
      71             :     PROP_AXIS_LABEL_POSITION,
      72             :     PROP_AXIS_TEXT_ROTATION,
      73             :     PROP_AXIS_TEXT_BREAK,
      74             :     PROP_AXIS_TEXT_OVERLAP,
      75             :     PROP_AXIS_TEXT_STACKED,
      76             :     PROP_AXIS_TEXT_ARRANGE_ORDER,
      77             :     PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
      78             : 
      79             :     PROP_AXIS_MAJOR_TICKMARKS,
      80             :     PROP_AXIS_MINOR_TICKMARKS,
      81             :     PROP_AXIS_MARK_POSITION
      82             : };
      83             : 
      84           2 : void lcl_AddPropertiesToVector(
      85             :     ::std::vector< Property > & rOutProperties )
      86             : {
      87             :     rOutProperties.push_back(
      88             :         Property( C2U( "Show" ),
      89             :                   PROP_AXIS_SHOW,
      90           2 :                   ::getBooleanCppuType(),
      91             :                   beans::PropertyAttribute::BOUND
      92           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      93             : 
      94             :     rOutProperties.push_back(
      95             :         Property( C2U( "CrossoverPosition" ),
      96             :                   PROP_AXIS_CROSSOVER_POSITION,
      97           2 :                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisPosition * >(0)),
      98           2 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
      99             : 
     100             :     rOutProperties.push_back(
     101             :         Property( C2U( "CrossoverValue" ),
     102             :                   PROP_AXIS_CROSSOVER_VALUE,
     103           2 :                   ::getCppuType( reinterpret_cast< const double * >(0)),
     104           2 :                   beans::PropertyAttribute::MAYBEVOID ));
     105             : 
     106             :     rOutProperties.push_back(
     107             :         Property( C2U( "DisplayLabels" ),
     108             :                   PROP_AXIS_DISPLAY_LABELS,
     109           2 :                   ::getBooleanCppuType(),
     110             :                   beans::PropertyAttribute::BOUND
     111           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     112             : 
     113             :     rOutProperties.push_back(
     114             :         Property( C2U( "NumberFormat" ),
     115             :                   PROP_AXIS_NUMBER_FORMAT,
     116           2 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     117             :                   beans::PropertyAttribute::BOUND
     118           4 :                   | beans::PropertyAttribute::MAYBEVOID ));
     119             : 
     120             :     rOutProperties.push_back(
     121             :         Property( C2U( "LabelPosition" ),
     122             :                   PROP_AXIS_LABEL_POSITION,
     123           2 :                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisLabelPosition * >(0)),
     124           2 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     125             : 
     126             :     rOutProperties.push_back(
     127             :         Property( C2U( "TextRotation" ),
     128             :                   PROP_AXIS_TEXT_ROTATION,
     129           2 :                   ::getCppuType( reinterpret_cast< const double * >(0)),
     130             :                   beans::PropertyAttribute::BOUND
     131           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     132             : 
     133             :     rOutProperties.push_back(
     134             :         Property( C2U( "TextBreak" ),
     135             :                   PROP_AXIS_TEXT_BREAK,
     136           2 :                   ::getBooleanCppuType(),
     137             :                   beans::PropertyAttribute::BOUND
     138           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     139             : 
     140             :     rOutProperties.push_back(
     141             :         Property( C2U( "TextOverlap" ),
     142             :                   PROP_AXIS_TEXT_OVERLAP,
     143           2 :                   ::getBooleanCppuType(),
     144             :                   beans::PropertyAttribute::BOUND
     145           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     146             : 
     147             :     rOutProperties.push_back(
     148             :         Property( C2U( "StackCharacters" ),
     149             :                   PROP_AXIS_TEXT_STACKED,
     150           2 :                   ::getBooleanCppuType(),
     151             :                   beans::PropertyAttribute::BOUND
     152           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     153             : 
     154             :     rOutProperties.push_back(
     155             :         Property( C2U( "ArrangeOrder" ),
     156             :                   PROP_AXIS_TEXT_ARRANGE_ORDER,
     157           2 :                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisArrangeOrderType * >(0)),
     158             :                   beans::PropertyAttribute::BOUND
     159           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     160             : 
     161             :     rOutProperties.push_back(
     162             :         Property( C2U( "ReferencePageSize" ),
     163             :                   PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
     164           2 :                   ::getCppuType( reinterpret_cast< const awt::Size * >(0)),
     165             :                   beans::PropertyAttribute::BOUND
     166           4 :                   | beans::PropertyAttribute::MAYBEVOID ));
     167             : 
     168             :     rOutProperties.push_back(
     169             :         Property( C2U( "MajorTickmarks" ),
     170             :                   PROP_AXIS_MAJOR_TICKMARKS,
     171           2 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     172             :                   beans::PropertyAttribute::BOUND
     173           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     174             :     rOutProperties.push_back(
     175             :         Property( C2U( "MinorTickmarks" ),
     176             :                   PROP_AXIS_MINOR_TICKMARKS,
     177           2 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     178             :                   beans::PropertyAttribute::BOUND
     179           4 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     180             :     rOutProperties.push_back(
     181             :         Property( C2U( "MarkPosition" ),
     182             :                   PROP_AXIS_MARK_POSITION,
     183           2 :                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisMarkPosition * >(0)),
     184           2 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     185           2 : }
     186             : 
     187             : struct StaticAxisDefaults_Initializer
     188             : {
     189           2 :     ::chart::tPropertyValueMap* operator()()
     190             :     {
     191           2 :         static ::chart::tPropertyValueMap aStaticDefaults;
     192           2 :         lcl_AddDefaultsToMap( aStaticDefaults );
     193           2 :         return &aStaticDefaults;
     194             :     }
     195             : private:
     196           2 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
     197             :     {
     198           2 :         ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
     199           2 :         ::chart::LineProperties::AddDefaultsToMap( rOutMap );
     200             : 
     201           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_SHOW, true );
     202           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_CROSSOVER_POSITION, ::com::sun::star::chart::ChartAxisPosition_ZERO );
     203           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_LABELS, true );
     204           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LABEL_POSITION, ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS );
     205           2 :         ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_AXIS_TEXT_ROTATION, 0.0 );
     206           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_BREAK, false );
     207           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_OVERLAP, false );
     208           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_STACKED, false );
     209           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_ARRANGE_ORDER, ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO );
     210             : 
     211           2 :         float fDefaultCharHeight = 10.0;
     212           2 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
     213           2 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
     214           2 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
     215             : 
     216           2 :         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ );
     217           2 :         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ );
     218           2 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_MARK_POSITION, ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
     219           2 :     }
     220             : };
     221             : 
     222             : struct StaticAxisDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAxisDefaults_Initializer >
     223             : {
     224             : };
     225             : 
     226             : struct StaticAxisInfoHelper_Initializer
     227             : {
     228           2 :     ::cppu::OPropertyArrayHelper* operator()()
     229             :     {
     230           2 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
     231           2 :         return &aPropHelper;
     232             :     }
     233             : 
     234             : private:
     235           2 :     Sequence< Property > lcl_GetPropertySequence()
     236             :     {
     237           2 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
     238           2 :         lcl_AddPropertiesToVector( aProperties );
     239           2 :         ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
     240           2 :         ::chart::LineProperties::AddPropertiesToVector( aProperties );
     241           2 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
     242             : 
     243             :         ::std::sort( aProperties.begin(), aProperties.end(),
     244           2 :                      ::chart::PropertyNameLess() );
     245             : 
     246           2 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
     247             :     }
     248             : };
     249             : 
     250             : struct StaticAxisInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAxisInfoHelper_Initializer >
     251             : {
     252             : };
     253             : 
     254             : struct StaticAxisInfo_Initializer
     255             : {
     256           0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
     257             :     {
     258             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
     259           0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAxisInfoHelper::get() ) );
     260           0 :         return &xPropertySetInfo;
     261             :     }
     262             : };
     263             : 
     264             : struct StaticAxisInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAxisInfo_Initializer >
     265             : {
     266             : };
     267             : 
     268             : typedef uno::Reference< beans::XPropertySet > lcl_tSubGridType;
     269             : typedef uno::Sequence< lcl_tSubGridType >     lcl_tSubGridSeq;
     270             : 
     271           0 : void lcl_CloneSubGrids(
     272             :     const lcl_tSubGridSeq & rSource, lcl_tSubGridSeq & rDestination )
     273             : {
     274           0 :     const lcl_tSubGridType * pBegin = rSource.getConstArray();
     275           0 :     const lcl_tSubGridType * pEnd = pBegin + rSource.getLength();
     276             : 
     277           0 :     rDestination.realloc( rSource.getLength());
     278           0 :     lcl_tSubGridType * pDestBegin = rDestination.getArray();
     279           0 :     lcl_tSubGridType * pDestEnd   = pDestBegin + rDestination.getLength();
     280           0 :     lcl_tSubGridType * pDestIt    = pDestBegin;
     281             : 
     282           0 :     for( const lcl_tSubGridType * pIt = pBegin; pIt != pEnd; ++pIt )
     283             :     {
     284           0 :         Reference< beans::XPropertySet > xSubGrid( *pIt );
     285           0 :         if( xSubGrid.is())
     286             :         {
     287           0 :             Reference< util::XCloneable > xCloneable( xSubGrid, uno::UNO_QUERY );
     288           0 :             if( xCloneable.is())
     289           0 :                 xSubGrid.set( xCloneable->createClone(), uno::UNO_QUERY );
     290             :         }
     291             : 
     292           0 :         (*pDestIt) = xSubGrid;
     293             :         OSL_ASSERT( pDestIt != pDestEnd );
     294           0 :         ++pDestIt;
     295           0 :     }
     296             :     OSL_ASSERT( pDestIt == pDestEnd );
     297             :     (void)(pDestEnd); // avoid warning
     298           0 : }
     299             : 
     300             : } // anonymous namespace
     301             : 
     302             : // ================================================================================
     303             : 
     304             : namespace chart
     305             : {
     306             : 
     307         484 : Axis::Axis( Reference< uno::XComponentContext > const & /* xContext */ ) :
     308             :         ::property::OPropertySet( m_aMutex ),
     309             :         m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
     310             :         m_aScaleData( AxisHelper::createDefaultScale() ),
     311           0 :         m_xGrid( new GridProperties() ),
     312             :         m_aSubGridProperties(),
     313         484 :         m_xTitle()
     314             : {
     315         484 :     osl_atomic_increment(&m_refCount);
     316             :     setFastPropertyValue_NoBroadcast(
     317         484 :         ::chart::LineProperties::PROP_LINE_COLOR, uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) );  // gray30
     318             : 
     319         484 :     if( m_xGrid.is())
     320         484 :         ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
     321         484 :     if( m_aScaleData.Categories.is())
     322           0 :         ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
     323             : 
     324         484 :     AllocateSubGrids();
     325         484 :     osl_atomic_decrement(&m_refCount);
     326         484 : }
     327             : 
     328           0 : Axis::Axis( const Axis & rOther ) :
     329             :         MutexContainer(),
     330             :         impl::Axis_Base(),
     331             :         ::property::OPropertySet( rOther, m_aMutex ),
     332             :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
     333           0 :     m_aScaleData( rOther.m_aScaleData )
     334             : {
     335           0 :     m_xGrid.set( CloneHelper::CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xGrid ));
     336           0 :     if( m_xGrid.is())
     337           0 :         ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
     338             : 
     339           0 :     if( m_aScaleData.Categories.is())
     340           0 :         ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
     341             : 
     342           0 :     if( rOther.m_aSubGridProperties.getLength() != 0 )
     343           0 :         lcl_CloneSubGrids( rOther.m_aSubGridProperties, m_aSubGridProperties );
     344           0 :     ModifyListenerHelper::addListenerToAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
     345             : 
     346           0 :     m_xTitle.set( CloneHelper::CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
     347           0 :     if( m_xTitle.is())
     348           0 :         ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
     349           0 : }
     350             : 
     351             : // late initialization to call after copy-constructing
     352           0 : void Axis::Init( const Axis & /* rOther */ )
     353             : {
     354           0 :     if( m_aScaleData.Categories.is())
     355           0 :         EventListenerHelper::addListener( m_aScaleData.Categories, this );
     356           0 : }
     357             : 
     358        1452 : Axis::~Axis()
     359             : {
     360             :     try
     361             :     {
     362         484 :         ModifyListenerHelper::removeListener( m_xGrid, m_xModifyEventForwarder );
     363         484 :         ModifyListenerHelper::removeListenerFromAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
     364         484 :         ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
     365         484 :         if( m_aScaleData.Categories.is())
     366             :         {
     367         124 :             ModifyListenerHelper::removeListener( m_aScaleData.Categories, m_xModifyEventForwarder );
     368         124 :             m_aScaleData.Categories.set(0);
     369             :         }
     370             :     }
     371           0 :     catch( const uno::Exception & ex )
     372             :     {
     373             :         ASSERT_EXCEPTION( ex );
     374             :     }
     375             : 
     376         484 :     m_aSubGridProperties.realloc(0);
     377         484 :     m_xGrid = 0;
     378         484 :     m_xTitle = 0;
     379         968 : }
     380             : 
     381        1214 : void Axis::AllocateSubGrids()
     382             : {
     383        1214 :     Reference< util::XModifyListener > xModifyEventForwarder;
     384        1214 :     Reference< lang::XEventListener > xEventListener;
     385        1214 :     std::vector< Reference< beans::XPropertySet > > aOldBroadcasters;
     386        1214 :     std::vector< Reference< beans::XPropertySet > > aNewBroadcasters;
     387             :     {
     388        1214 :         MutexGuard aGuard( m_aMutex );
     389        1214 :         xModifyEventForwarder = m_xModifyEventForwarder;
     390        1214 :         xEventListener = this;
     391             : 
     392        1214 :         sal_Int32 nNewSubIncCount = m_aScaleData.IncrementData.SubIncrements.getLength();
     393        1214 :         sal_Int32 nOldSubIncCount = m_aSubGridProperties.getLength();
     394             : 
     395        1214 :         if( nOldSubIncCount > nNewSubIncCount )
     396             :         {
     397             :             // remove superfluous entries
     398           0 :             for( sal_Int32 i = nNewSubIncCount; i < nOldSubIncCount; ++i )
     399           0 :                 aOldBroadcasters.push_back( m_aSubGridProperties[ i ] );
     400           0 :             m_aSubGridProperties.realloc( nNewSubIncCount );
     401             :         }
     402        1214 :         else if( nOldSubIncCount < nNewSubIncCount )
     403             :         {
     404         484 :             m_aSubGridProperties.realloc( nNewSubIncCount );
     405             : 
     406             :             // allocate new entries
     407         968 :             for( sal_Int32 i = nOldSubIncCount; i < nNewSubIncCount; ++i )
     408             :             {
     409         484 :                 m_aSubGridProperties[ i ] = new GridProperties();
     410         484 :                 LineProperties::SetLineInvisible( m_aSubGridProperties[ i ] );
     411         484 :                 aNewBroadcasters.push_back( m_aSubGridProperties[ i ] );
     412             :             }
     413        1214 :         }
     414             :     }
     415             :     //don't keep the mutex locked while calling out
     416        1214 :     std::vector< Reference< beans::XPropertySet > >::iterator aBroadcaster = aOldBroadcasters.begin();
     417        1214 :     for( ;aBroadcaster != aOldBroadcasters.end(); ++aBroadcaster )
     418           0 :         ModifyListenerHelper::removeListener( *aBroadcaster, xModifyEventForwarder );
     419        1698 :     for( aBroadcaster = aNewBroadcasters.begin(); aBroadcaster != aNewBroadcasters.end(); ++aBroadcaster )
     420        1698 :         ModifyListenerHelper::addListener( *aBroadcaster, xModifyEventForwarder );
     421        1214 : }
     422             : 
     423             : // --------------------------------------------------------------------------------
     424             : 
     425             : // ____ XAxis ____
     426         730 : void SAL_CALL Axis::setScaleData( const chart2::ScaleData& rScaleData )
     427             :     throw (uno::RuntimeException)
     428             : {
     429         730 :     Reference< util::XModifyListener > xModifyEventForwarder;
     430         730 :     Reference< lang::XEventListener > xEventListener;
     431         730 :     Reference< chart2::data::XLabeledDataSequence > xOldCategories;
     432         730 :     Reference< chart2::data::XLabeledDataSequence > xNewCategories = rScaleData.Categories;
     433             :     {
     434         730 :         MutexGuard aGuard( m_aMutex );
     435         730 :         xModifyEventForwarder = m_xModifyEventForwarder;
     436         730 :         xEventListener = this;
     437         730 :         xOldCategories = m_aScaleData.Categories;
     438         730 :         m_aScaleData = rScaleData;
     439             :     }
     440         730 :     AllocateSubGrids();
     441             : 
     442             :     //don't keep the mutex locked while calling out
     443         730 :     if( xOldCategories.is() && xOldCategories != xNewCategories )
     444             :     {
     445           0 :         ModifyListenerHelper::removeListener( xOldCategories, xModifyEventForwarder );
     446           0 :         EventListenerHelper::removeListener( xOldCategories, xEventListener );
     447             :     }
     448         730 :     if( xNewCategories.is() && xOldCategories != xNewCategories )
     449             :     {
     450         124 :         ModifyListenerHelper::addListener( xNewCategories, m_xModifyEventForwarder );
     451         124 :         EventListenerHelper::addListener( xNewCategories, xEventListener );
     452             :     }
     453         730 :     fireModifyEvent();
     454         730 : }
     455             : 
     456        2522 : chart2::ScaleData SAL_CALL Axis::getScaleData()
     457             :     throw (uno::RuntimeException)
     458             : {
     459        2522 :     MutexGuard aGuard( m_aMutex );
     460        2522 :     return m_aScaleData;
     461             : }
     462             : 
     463         406 : Reference< beans::XPropertySet > SAL_CALL Axis::getGridProperties()
     464             :     throw (uno::RuntimeException)
     465             : {
     466         406 :     MutexGuard aGuard( m_aMutex );
     467         406 :     return m_xGrid;
     468             : }
     469         324 : Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubGridProperties()
     470             :     throw (uno::RuntimeException)
     471             : {
     472         324 :     MutexGuard aGuard( m_aMutex );
     473         324 :     return m_aSubGridProperties;
     474             : }
     475             : 
     476           0 : Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubTickProperties()
     477             :     throw (uno::RuntimeException)
     478             : {
     479             :     OSL_FAIL( "Not implemented yet" );
     480           0 :     return Sequence< Reference< beans::XPropertySet > >();
     481             : }
     482             : 
     483             : 
     484             : // ____ XTitled ____
     485         164 : Reference< chart2::XTitle > SAL_CALL Axis::getTitleObject()
     486             :     throw (uno::RuntimeException)
     487             : {
     488         164 :     MutexGuard aGuard( GetMutex() );
     489         164 :     return m_xTitle;
     490             : }
     491             : 
     492           0 : void SAL_CALL Axis::setTitleObject( const Reference< chart2::XTitle >& xNewTitle )
     493             :     throw (uno::RuntimeException)
     494             : {
     495           0 :     Reference< util::XModifyListener > xModifyEventForwarder;
     496           0 :     Reference< chart2::XTitle > xOldTitle;
     497             :     {
     498           0 :         MutexGuard aGuard( GetMutex() );
     499           0 :         xOldTitle = m_xTitle;
     500           0 :         xModifyEventForwarder = m_xModifyEventForwarder;
     501           0 :         m_xTitle = xNewTitle;
     502             :     }
     503             : 
     504             :     //don't keep the mutex locked while calling out
     505           0 :     if( xOldTitle.is() && xOldTitle != xNewTitle )
     506           0 :         ModifyListenerHelper::removeListener( xOldTitle, xModifyEventForwarder );
     507           0 :     if( xNewTitle.is() && xOldTitle != xNewTitle )
     508           0 :         ModifyListenerHelper::addListener( xNewTitle, xModifyEventForwarder );
     509           0 :     fireModifyEvent();
     510           0 : }
     511             : 
     512             : // ____ XCloneable ____
     513           0 : Reference< util::XCloneable > SAL_CALL Axis::createClone()
     514             :     throw (uno::RuntimeException)
     515             : {
     516           0 :     Axis * pNewAxis( new Axis( *this ));
     517             :     // hold a reference to the clone
     518           0 :     Reference< util::XCloneable > xResult( pNewAxis );
     519             :     // do initialization that uses uno references to the clone
     520           0 :     pNewAxis->Init( *this );
     521           0 :     return xResult;
     522             : }
     523             : 
     524             : // ____ XModifyBroadcaster ____
     525         484 : void SAL_CALL Axis::addModifyListener( const Reference< util::XModifyListener >& aListener )
     526             :     throw (uno::RuntimeException)
     527             : {
     528             :     try
     529             :     {
     530         484 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     531         484 :         xBroadcaster->addModifyListener( aListener );
     532             :     }
     533           0 :     catch( const uno::Exception & ex )
     534             :     {
     535             :         ASSERT_EXCEPTION( ex );
     536             :     }
     537         484 : }
     538             : 
     539         484 : void SAL_CALL Axis::removeModifyListener( const Reference< util::XModifyListener >& aListener )
     540             :     throw (uno::RuntimeException)
     541             : {
     542             :     try
     543             :     {
     544         484 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     545         484 :         xBroadcaster->removeModifyListener( aListener );
     546             :     }
     547           0 :     catch( const uno::Exception & ex )
     548             :     {
     549             :         ASSERT_EXCEPTION( ex );
     550             :     }
     551         484 : }
     552             : 
     553             : // ____ XModifyListener ____
     554           0 : void SAL_CALL Axis::modified( const lang::EventObject& aEvent )
     555             :     throw (uno::RuntimeException)
     556             : {
     557           0 :     m_xModifyEventForwarder->modified( aEvent );
     558           0 : }
     559             : 
     560             : // ____ XEventListener (base of XModifyListener) ____
     561           0 : void SAL_CALL Axis::disposing( const lang::EventObject& Source )
     562             :     throw (uno::RuntimeException)
     563             : {
     564           0 :     if( Source.Source == m_aScaleData.Categories )
     565           0 :         m_aScaleData.Categories = 0;
     566           0 : }
     567             : 
     568             : // ____ OPropertySet ____
     569        2328 : void Axis::firePropertyChangeEvent()
     570             : {
     571        2328 :     fireModifyEvent();
     572        2328 : }
     573             : 
     574        3058 : void Axis::fireModifyEvent()
     575             : {
     576        3058 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
     577        3058 : }
     578             : 
     579             : // ================================================================================
     580             : 
     581             : // ____ OPropertySet ____
     582       24936 : uno::Any Axis::GetDefaultValue( sal_Int32 nHandle ) const
     583             :     throw(beans::UnknownPropertyException)
     584             : {
     585       24936 :     const tPropertyValueMap& rStaticDefaults = *StaticAxisDefaults::get();
     586       24936 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     587       24936 :     if( aFound == rStaticDefaults.end() )
     588        1628 :         return uno::Any();
     589       23308 :     return (*aFound).second;
     590             : }
     591             : 
     592       43576 : ::cppu::IPropertyArrayHelper & SAL_CALL Axis::getInfoHelper()
     593             : {
     594       43576 :     return *StaticAxisInfoHelper::get();
     595             : }
     596             : 
     597             : // ____ XPropertySet ____
     598           0 : Reference< beans::XPropertySetInfo > SAL_CALL Axis::getPropertySetInfo()
     599             :     throw (uno::RuntimeException)
     600             : {
     601           0 :     return *StaticAxisInfo::get();
     602             : }
     603             : 
     604             : // ================================================================================
     605             : 
     606           2 : Sequence< OUString > Axis::getSupportedServiceNames_Static()
     607             : {
     608           2 :     Sequence< OUString > aServices( 2 );
     609           2 :     aServices[ 0 ] = C2U( "com.sun.star.chart2.Axis" );
     610           2 :     aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
     611           2 :     return aServices;
     612             : }
     613             : 
     614             : using impl::Axis_Base;
     615             : 
     616       69848 : IMPLEMENT_FORWARD_XINTERFACE2( Axis, Axis_Base, ::property::OPropertySet )
     617           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( Axis, Axis_Base, ::property::OPropertySet )
     618             : 
     619             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     620          34 : APPHELPER_XSERVICEINFO_IMPL( Axis, lcl_aServiceName );
     621             : 
     622           6 : } //  namespace chart
     623             : 
     624             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10