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-27 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           1 : 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           1 : void lcl_AddPropertiesToVector(
      85             :     ::std::vector< Property > & rOutProperties )
      86             : {
      87             :     rOutProperties.push_back(
      88             :         Property( C2U( "Show" ),
      89             :                   PROP_AXIS_SHOW,
      90           1 :                   ::getBooleanCppuType(),
      91             :                   beans::PropertyAttribute::BOUND
      92           2 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
      93             : 
      94             :     rOutProperties.push_back(
      95             :         Property( C2U( "CrossoverPosition" ),
      96             :                   PROP_AXIS_CROSSOVER_POSITION,
      97           1 :                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisPosition * >(0)),
      98           1 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
      99             : 
     100             :     rOutProperties.push_back(
     101             :         Property( C2U( "CrossoverValue" ),
     102             :                   PROP_AXIS_CROSSOVER_VALUE,
     103           1 :                   ::getCppuType( reinterpret_cast< const double * >(0)),
     104           1 :                   beans::PropertyAttribute::MAYBEVOID ));
     105             : 
     106             :     rOutProperties.push_back(
     107             :         Property( C2U( "DisplayLabels" ),
     108             :                   PROP_AXIS_DISPLAY_LABELS,
     109           1 :                   ::getBooleanCppuType(),
     110             :                   beans::PropertyAttribute::BOUND
     111           2 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     112             : 
     113             :     rOutProperties.push_back(
     114             :         Property( C2U( "NumberFormat" ),
     115             :                   PROP_AXIS_NUMBER_FORMAT,
     116           1 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     117             :                   beans::PropertyAttribute::BOUND
     118           2 :                   | beans::PropertyAttribute::MAYBEVOID ));
     119             : 
     120             :     rOutProperties.push_back(
     121             :         Property( C2U( "LabelPosition" ),
     122             :                   PROP_AXIS_LABEL_POSITION,
     123           1 :                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisLabelPosition * >(0)),
     124           1 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     125             : 
     126             :     rOutProperties.push_back(
     127             :         Property( C2U( "TextRotation" ),
     128             :                   PROP_AXIS_TEXT_ROTATION,
     129           1 :                   ::getCppuType( reinterpret_cast< const double * >(0)),
     130             :                   beans::PropertyAttribute::BOUND
     131           2 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     132             : 
     133             :     rOutProperties.push_back(
     134             :         Property( C2U( "TextBreak" ),
     135             :                   PROP_AXIS_TEXT_BREAK,
     136           1 :                   ::getBooleanCppuType(),
     137             :                   beans::PropertyAttribute::BOUND
     138           2 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     139             : 
     140             :     rOutProperties.push_back(
     141             :         Property( C2U( "TextOverlap" ),
     142             :                   PROP_AXIS_TEXT_OVERLAP,
     143           1 :                   ::getBooleanCppuType(),
     144             :                   beans::PropertyAttribute::BOUND
     145           2 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     146             : 
     147             :     rOutProperties.push_back(
     148             :         Property( C2U( "StackCharacters" ),
     149             :                   PROP_AXIS_TEXT_STACKED,
     150           1 :                   ::getBooleanCppuType(),
     151             :                   beans::PropertyAttribute::BOUND
     152           2 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     153             : 
     154             :     rOutProperties.push_back(
     155             :         Property( C2U( "ArrangeOrder" ),
     156             :                   PROP_AXIS_TEXT_ARRANGE_ORDER,
     157           1 :                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisArrangeOrderType * >(0)),
     158             :                   beans::PropertyAttribute::BOUND
     159           2 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     160             : 
     161             :     rOutProperties.push_back(
     162             :         Property( C2U( "ReferencePageSize" ),
     163             :                   PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
     164           1 :                   ::getCppuType( reinterpret_cast< const awt::Size * >(0)),
     165             :                   beans::PropertyAttribute::BOUND
     166           2 :                   | beans::PropertyAttribute::MAYBEVOID ));
     167             : 
     168             :     rOutProperties.push_back(
     169             :         Property( C2U( "MajorTickmarks" ),
     170             :                   PROP_AXIS_MAJOR_TICKMARKS,
     171           1 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     172             :                   beans::PropertyAttribute::BOUND
     173           2 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     174             :     rOutProperties.push_back(
     175             :         Property( C2U( "MinorTickmarks" ),
     176             :                   PROP_AXIS_MINOR_TICKMARKS,
     177           1 :                   ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
     178             :                   beans::PropertyAttribute::BOUND
     179           2 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     180             :     rOutProperties.push_back(
     181             :         Property( C2U( "MarkPosition" ),
     182             :                   PROP_AXIS_MARK_POSITION,
     183           1 :                   ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisMarkPosition * >(0)),
     184           1 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     185           1 : }
     186             : 
     187             : struct StaticAxisDefaults_Initializer
     188             : {
     189           1 :     ::chart::tPropertyValueMap* operator()()
     190             :     {
     191           1 :         static ::chart::tPropertyValueMap aStaticDefaults;
     192           1 :         lcl_AddDefaultsToMap( aStaticDefaults );
     193           1 :         return &aStaticDefaults;
     194             :     }
     195             : private:
     196           1 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
     197             :     {
     198           1 :         ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
     199           1 :         ::chart::LineProperties::AddDefaultsToMap( rOutMap );
     200             : 
     201           1 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_SHOW, true );
     202           1 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_CROSSOVER_POSITION, ::com::sun::star::chart::ChartAxisPosition_ZERO );
     203           1 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_LABELS, true );
     204           1 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LABEL_POSITION, ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS );
     205           1 :         ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_AXIS_TEXT_ROTATION, 0.0 );
     206           1 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_BREAK, false );
     207           1 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_OVERLAP, false );
     208           1 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_STACKED, false );
     209           1 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_ARRANGE_ORDER, ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO );
     210             : 
     211           1 :         float fDefaultCharHeight = 10.0;
     212           1 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
     213           1 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
     214           1 :         ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
     215             : 
     216           1 :         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ );
     217           1 :         ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ );
     218           1 :         ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_MARK_POSITION, ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
     219           1 :     }
     220             : };
     221             : 
     222             : struct StaticAxisDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAxisDefaults_Initializer >
     223             : {
     224             : };
     225             : 
     226             : struct StaticAxisInfoHelper_Initializer
     227             : {
     228           1 :     ::cppu::OPropertyArrayHelper* operator()()
     229             :     {
     230           1 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
     231           1 :         return &aPropHelper;
     232             :     }
     233             : 
     234             : private:
     235           1 :     Sequence< Property > lcl_GetPropertySequence()
     236             :     {
     237           1 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
     238           1 :         lcl_AddPropertiesToVector( aProperties );
     239           1 :         ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
     240           1 :         ::chart::LineProperties::AddPropertiesToVector( aProperties );
     241           1 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
     242             : 
     243             :         ::std::sort( aProperties.begin(), aProperties.end(),
     244           1 :                      ::chart::PropertyNameLess() );
     245             : 
     246           1 :         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         242 : 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         242 :         m_xTitle()
     314             : {
     315         242 :     osl_atomic_increment(&m_refCount);
     316             :     setFastPropertyValue_NoBroadcast(
     317         242 :         ::chart::LineProperties::PROP_LINE_COLOR, uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) );  // gray30
     318             : 
     319         242 :     if( m_xGrid.is())
     320         242 :         ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
     321         242 :     if( m_aScaleData.Categories.is())
     322           0 :         ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
     323             : 
     324         242 :     AllocateSubGrids();
     325         242 :     osl_atomic_decrement(&m_refCount);
     326         242 : }
     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         726 : Axis::~Axis()
     359             : {
     360             :     try
     361             :     {
     362         242 :         ModifyListenerHelper::removeListener( m_xGrid, m_xModifyEventForwarder );
     363         242 :         ModifyListenerHelper::removeListenerFromAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
     364         242 :         ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
     365         242 :         if( m_aScaleData.Categories.is())
     366             :         {
     367          62 :             ModifyListenerHelper::removeListener( m_aScaleData.Categories, m_xModifyEventForwarder );
     368          62 :             m_aScaleData.Categories.set(0);
     369             :         }
     370             :     }
     371           0 :     catch( const uno::Exception & ex )
     372             :     {
     373             :         ASSERT_EXCEPTION( ex );
     374             :     }
     375             : 
     376         242 :     m_aSubGridProperties.realloc(0);
     377         242 :     m_xGrid = 0;
     378         242 :     m_xTitle = 0;
     379         484 : }
     380             : 
     381         607 : void Axis::AllocateSubGrids()
     382             : {
     383         607 :     Reference< util::XModifyListener > xModifyEventForwarder;
     384         607 :     Reference< lang::XEventListener > xEventListener;
     385         607 :     std::vector< Reference< beans::XPropertySet > > aOldBroadcasters;
     386         607 :     std::vector< Reference< beans::XPropertySet > > aNewBroadcasters;
     387             :     {
     388         607 :         MutexGuard aGuard( m_aMutex );
     389         607 :         xModifyEventForwarder = m_xModifyEventForwarder;
     390         607 :         xEventListener = this;
     391             : 
     392         607 :         sal_Int32 nNewSubIncCount = m_aScaleData.IncrementData.SubIncrements.getLength();
     393         607 :         sal_Int32 nOldSubIncCount = m_aSubGridProperties.getLength();
     394             : 
     395         607 :         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         607 :         else if( nOldSubIncCount < nNewSubIncCount )
     403             :         {
     404         242 :             m_aSubGridProperties.realloc( nNewSubIncCount );
     405             : 
     406             :             // allocate new entries
     407         484 :             for( sal_Int32 i = nOldSubIncCount; i < nNewSubIncCount; ++i )
     408             :             {
     409         242 :                 m_aSubGridProperties[ i ] = new GridProperties();
     410         242 :                 LineProperties::SetLineInvisible( m_aSubGridProperties[ i ] );
     411         242 :                 aNewBroadcasters.push_back( m_aSubGridProperties[ i ] );
     412             :             }
     413         607 :         }
     414             :     }
     415             :     //don't keep the mutex locked while calling out
     416         607 :     std::vector< Reference< beans::XPropertySet > >::iterator aBroadcaster = aOldBroadcasters.begin();
     417         607 :     for( ;aBroadcaster != aOldBroadcasters.end(); ++aBroadcaster )
     418           0 :         ModifyListenerHelper::removeListener( *aBroadcaster, xModifyEventForwarder );
     419         849 :     for( aBroadcaster = aNewBroadcasters.begin(); aBroadcaster != aNewBroadcasters.end(); ++aBroadcaster )
     420         849 :         ModifyListenerHelper::addListener( *aBroadcaster, xModifyEventForwarder );
     421         607 : }
     422             : 
     423             : // --------------------------------------------------------------------------------
     424             : 
     425             : // ____ XAxis ____
     426         365 : void SAL_CALL Axis::setScaleData( const chart2::ScaleData& rScaleData )
     427             :     throw (uno::RuntimeException)
     428             : {
     429         365 :     Reference< util::XModifyListener > xModifyEventForwarder;
     430         365 :     Reference< lang::XEventListener > xEventListener;
     431         365 :     Reference< chart2::data::XLabeledDataSequence > xOldCategories;
     432         365 :     Reference< chart2::data::XLabeledDataSequence > xNewCategories = rScaleData.Categories;
     433             :     {
     434         365 :         MutexGuard aGuard( m_aMutex );
     435         365 :         xModifyEventForwarder = m_xModifyEventForwarder;
     436         365 :         xEventListener = this;
     437         365 :         xOldCategories = m_aScaleData.Categories;
     438         365 :         m_aScaleData = rScaleData;
     439             :     }
     440         365 :     AllocateSubGrids();
     441             : 
     442             :     //don't keep the mutex locked while calling out
     443         365 :     if( xOldCategories.is() && xOldCategories != xNewCategories )
     444             :     {
     445           0 :         ModifyListenerHelper::removeListener( xOldCategories, xModifyEventForwarder );
     446           0 :         EventListenerHelper::removeListener( xOldCategories, xEventListener );
     447             :     }
     448         365 :     if( xNewCategories.is() && xOldCategories != xNewCategories )
     449             :     {
     450          62 :         ModifyListenerHelper::addListener( xNewCategories, m_xModifyEventForwarder );
     451          62 :         EventListenerHelper::addListener( xNewCategories, xEventListener );
     452             :     }
     453         365 :     fireModifyEvent();
     454         365 : }
     455             : 
     456        1141 : chart2::ScaleData SAL_CALL Axis::getScaleData()
     457             :     throw (uno::RuntimeException)
     458             : {
     459        1141 :     MutexGuard aGuard( m_aMutex );
     460        1141 :     return m_aScaleData;
     461             : }
     462             : 
     463         203 : Reference< beans::XPropertySet > SAL_CALL Axis::getGridProperties()
     464             :     throw (uno::RuntimeException)
     465             : {
     466         203 :     MutexGuard aGuard( m_aMutex );
     467         203 :     return m_xGrid;
     468             : }
     469         162 : Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubGridProperties()
     470             :     throw (uno::RuntimeException)
     471             : {
     472         162 :     MutexGuard aGuard( m_aMutex );
     473         162 :     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          82 : Reference< chart2::XTitle > SAL_CALL Axis::getTitleObject()
     486             :     throw (uno::RuntimeException)
     487             : {
     488          82 :     MutexGuard aGuard( GetMutex() );
     489          82 :     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         242 : void SAL_CALL Axis::addModifyListener( const Reference< util::XModifyListener >& aListener )
     526             :     throw (uno::RuntimeException)
     527             : {
     528             :     try
     529             :     {
     530         242 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     531         242 :         xBroadcaster->addModifyListener( aListener );
     532             :     }
     533           0 :     catch( const uno::Exception & ex )
     534             :     {
     535             :         ASSERT_EXCEPTION( ex );
     536             :     }
     537         242 : }
     538             : 
     539         242 : void SAL_CALL Axis::removeModifyListener( const Reference< util::XModifyListener >& aListener )
     540             :     throw (uno::RuntimeException)
     541             : {
     542             :     try
     543             :     {
     544         242 :         Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     545         242 :         xBroadcaster->removeModifyListener( aListener );
     546             :     }
     547           0 :     catch( const uno::Exception & ex )
     548             :     {
     549             :         ASSERT_EXCEPTION( ex );
     550             :     }
     551         242 : }
     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        1164 : void Axis::firePropertyChangeEvent()
     570             : {
     571        1164 :     fireModifyEvent();
     572        1164 : }
     573             : 
     574        1529 : void Axis::fireModifyEvent()
     575             : {
     576        1529 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
     577        1529 : }
     578             : 
     579             : // ================================================================================
     580             : 
     581             : // ____ OPropertySet ____
     582       12468 : uno::Any Axis::GetDefaultValue( sal_Int32 nHandle ) const
     583             :     throw(beans::UnknownPropertyException)
     584             : {
     585       12468 :     const tPropertyValueMap& rStaticDefaults = *StaticAxisDefaults::get();
     586       12468 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     587       12468 :     if( aFound == rStaticDefaults.end() )
     588         814 :         return uno::Any();
     589       11654 :     return (*aFound).second;
     590             : }
     591             : 
     592       21788 : ::cppu::IPropertyArrayHelper & SAL_CALL Axis::getInfoHelper()
     593             : {
     594       21788 :     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           1 : Sequence< OUString > Axis::getSupportedServiceNames_Static()
     607             : {
     608           1 :     Sequence< OUString > aServices( 2 );
     609           1 :     aServices[ 0 ] = C2U( "com.sun.star.chart2.Axis" );
     610           1 :     aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" );
     611           1 :     return aServices;
     612             : }
     613             : 
     614             : using impl::Axis_Base;
     615             : 
     616       34542 : 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          16 : APPHELPER_XSERVICEINFO_IMPL( Axis, lcl_aServiceName );
     621             : 
     622           3 : } //  namespace chart
     623             : 
     624             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10