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

Generated by: LCOV version 1.11