LCOV - code coverage report
Current view: top level - chart2/source/model/main - Axis.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 185 250 74.0 %
Date: 2012-08-25 Functions: 28 42 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 203 502 40.4 %

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

Generated by: LCOV version 1.10