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

Generated by: LCOV version 1.10