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

Generated by: LCOV version 1.10