LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - AxisWrapper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 209 255 82.0 %
Date: 2015-06-13 12:38:46 Functions: 20 32 62.5 %
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 "AxisWrapper.hxx"
      21             : #include "AxisHelper.hxx"
      22             : #include "TitleHelper.hxx"
      23             : #include "Chart2ModelContact.hxx"
      24             : #include "ContainerHelper.hxx"
      25             : #include "macros.hxx"
      26             : #include "WrappedDirectStateProperty.hxx"
      27             : #include "GridWrapper.hxx"
      28             : #include "TitleWrapper.hxx"
      29             : #include "DisposeHelper.hxx"
      30             : #include <unonames.hxx>
      31             : 
      32             : #include <cppuhelper/supportsservice.hxx>
      33             : #include <comphelper/InlineContainer.hxx>
      34             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      35             : #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
      36             : #include <com/sun/star/chart/ChartAxisPosition.hpp>
      37             : #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
      38             : #include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
      39             : 
      40             : #include "CharacterProperties.hxx"
      41             : #include "LinePropertiesHelper.hxx"
      42             : #include "UserDefinedProperties.hxx"
      43             : #include "WrappedCharacterHeightProperty.hxx"
      44             : #include "WrappedTextRotationProperty.hxx"
      45             : #include "WrappedGapwidthProperty.hxx"
      46             : #include "WrappedScaleProperty.hxx"
      47             : #include "WrappedDefaultProperty.hxx"
      48             : #include "WrappedNumberFormatProperty.hxx"
      49             : #include "WrappedScaleTextProperties.hxx"
      50             : 
      51             : #include <algorithm>
      52             : #include <rtl/ustrbuf.hxx>
      53             : #include <rtl/math.hxx>
      54             : 
      55             : using namespace ::com::sun::star;
      56             : using namespace ::com::sun::star::chart2;
      57             : using namespace ::chart::ContainerHelper;
      58             : 
      59             : using ::com::sun::star::beans::Property;
      60             : using ::osl::MutexGuard;
      61             : using ::com::sun::star::uno::Reference;
      62             : using ::com::sun::star::uno::Sequence;
      63             : using ::com::sun::star::uno::Any;
      64             : 
      65             : namespace
      66             : {
      67             : static const char lcl_aServiceName[] = "com.sun.star.comp.chart.Axis";
      68             : 
      69             : enum
      70             : {
      71             :     PROP_AXIS_MAX,
      72             :     PROP_AXIS_MIN,
      73             :     PROP_AXIS_STEPMAIN,
      74             :     PROP_AXIS_STEPHELP, //deprecated property use 'StepHelpCount' instead
      75             :     PROP_AXIS_STEPHELP_COUNT,
      76             :     PROP_AXIS_AUTO_MAX,
      77             :     PROP_AXIS_AUTO_MIN,
      78             :     PROP_AXIS_AUTO_STEPMAIN,
      79             :     PROP_AXIS_AUTO_STEPHELP,
      80             :     PROP_AXIS_TYPE,
      81             :     PROP_AXIS_TIME_INCREMENT,
      82             :     PROP_AXIS_EXPLICIT_TIME_INCREMENT,
      83             :     PROP_AXIS_LOGARITHMIC,
      84             :     PROP_AXIS_REVERSEDIRECTION,
      85             :     PROP_AXIS_VISIBLE,
      86             :     PROP_AXIS_CROSSOVER_POSITION,
      87             :     PROP_AXIS_CROSSOVER_VALUE,
      88             :     PROP_AXIS_ORIGIN,
      89             :     PROP_AXIS_AUTO_ORIGIN,
      90             :     PROP_AXIS_MARKS,
      91             :     PROP_AXIS_HELPMARKS,
      92             :     PROP_AXIS_MARK_POSITION,
      93             :     PROP_AXIS_DISPLAY_LABELS,
      94             :     PROP_AXIS_NUMBERFORMAT,
      95             :     PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
      96             :     PROP_AXIS_LABEL_POSITION,
      97             :     PROP_AXIS_TEXT_ROTATION,
      98             :     PROP_AXIS_ARRANGE_ORDER,
      99             :     PROP_AXIS_TEXTBREAK,
     100             :     PROP_AXIS_CAN_OVERLAP,
     101             :     PROP_AXIS_STACKEDTEXT,
     102             :     PROP_AXIS_OVERLAP,
     103             :     PROP_AXIS_GAP_WIDTH,
     104             :     PROP_AXIS_DISPLAY_UNITS,
     105             :     PROP_AXIS_BUILTINUNIT
     106             : };
     107             : 
     108          11 : void lcl_AddPropertiesToVector(
     109             :     ::std::vector< Property > & rOutProperties )
     110             : {
     111             :     //Properties for scaling:
     112             :     rOutProperties.push_back(
     113             :         Property( "Max",
     114             :                   PROP_AXIS_MAX,
     115          11 :                   cppu::UnoType<double>::get(),
     116             :                   beans::PropertyAttribute::BOUND
     117          22 :                   | beans::PropertyAttribute::MAYBEVOID ));
     118             : 
     119             :     rOutProperties.push_back(
     120             :         Property( "Min",
     121             :                   PROP_AXIS_MIN,
     122          11 :                   cppu::UnoType<double>::get(),
     123             :                   beans::PropertyAttribute::BOUND
     124          22 :                   | beans::PropertyAttribute::MAYBEVOID ));
     125             : 
     126             :     rOutProperties.push_back(
     127             :         Property( "StepMain",
     128             :                   PROP_AXIS_STEPMAIN,
     129          11 :                   cppu::UnoType<double>::get(),
     130             :                   beans::PropertyAttribute::BOUND
     131          22 :                   | beans::PropertyAttribute::MAYBEVOID ));
     132             : 
     133             :     rOutProperties.push_back(
     134             :         Property( "StepHelpCount",
     135             :                   PROP_AXIS_STEPHELP_COUNT,
     136          11 :                   cppu::UnoType<sal_Int32>::get(),
     137             :                   beans::PropertyAttribute::BOUND
     138          22 :                   | beans::PropertyAttribute::MAYBEVOID ));
     139             : 
     140             :     //deprecated property use 'StepHelpCount' instead
     141             :     rOutProperties.push_back(
     142             :         Property( "StepHelp",
     143             :                   PROP_AXIS_STEPHELP,
     144          11 :                   cppu::UnoType<double>::get(),
     145             :                   beans::PropertyAttribute::BOUND
     146          22 :                   | beans::PropertyAttribute::MAYBEVOID ));
     147             : 
     148             :     rOutProperties.push_back(
     149             :         Property( "AutoMax",
     150             :                   PROP_AXIS_AUTO_MAX,
     151          11 :                   cppu::UnoType<bool>::get(),
     152             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     153          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     154             : 
     155             :     rOutProperties.push_back(
     156             :         Property( "AutoMin",
     157             :                   PROP_AXIS_AUTO_MIN,
     158          11 :                   cppu::UnoType<bool>::get(),
     159             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     160          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     161             : 
     162             :     rOutProperties.push_back(
     163             :         Property( "AutoStepMain",
     164             :                   PROP_AXIS_AUTO_STEPMAIN,
     165          11 :                   cppu::UnoType<bool>::get(),
     166             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     167          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     168             : 
     169             :     rOutProperties.push_back(
     170             :         Property( "AutoStepHelp",
     171             :                   PROP_AXIS_AUTO_STEPHELP,
     172          11 :                   cppu::UnoType<bool>::get(),
     173             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     174          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     175             : 
     176             :     rOutProperties.push_back(
     177             :         Property( "AxisType",
     178             :                   PROP_AXIS_TYPE,
     179          11 :                   cppu::UnoType<sal_Int32>::get(), //type com::sun::star::chart::ChartAxisType
     180             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     181          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     182             : 
     183             :     rOutProperties.push_back(
     184             :         Property( "TimeIncrement",
     185             :                   PROP_AXIS_TIME_INCREMENT,
     186          11 :                   cppu::UnoType<com::sun::star::chart::TimeIncrement>::get(),
     187             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     188          11 :                   beans::PropertyAttribute::MAYBEVOID ));
     189             : 
     190             :     rOutProperties.push_back(
     191             :         Property( "ExplicitTimeIncrement",
     192             :                   PROP_AXIS_EXPLICIT_TIME_INCREMENT,
     193          11 :                   cppu::UnoType<com::sun::star::chart::TimeIncrement>::get(),
     194             :                   beans::PropertyAttribute::READONLY |
     195          22 :                   beans::PropertyAttribute::MAYBEVOID ));
     196             : 
     197             :     rOutProperties.push_back(
     198             :         Property( "Logarithmic",
     199             :                   PROP_AXIS_LOGARITHMIC,
     200          11 :                   cppu::UnoType<bool>::get(),
     201             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     202          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     203             : 
     204             :     rOutProperties.push_back(
     205             :         Property( "ReverseDirection",
     206             :                   PROP_AXIS_REVERSEDIRECTION,
     207          11 :                   cppu::UnoType<bool>::get(),
     208             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     209          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     210             : 
     211             :     //todo: this property is missing in the API
     212             :     rOutProperties.push_back(
     213             :         Property( "Visible",
     214             :                   PROP_AXIS_VISIBLE,
     215          11 :                   cppu::UnoType<bool>::get(),
     216             :                   beans::PropertyAttribute::BOUND
     217          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     218             : 
     219             :     rOutProperties.push_back(
     220             :         Property( "CrossoverPosition",
     221             :                   PROP_AXIS_CROSSOVER_POSITION,
     222          11 :                   cppu::UnoType<com::sun::star::chart::ChartAxisPosition>::get(),
     223          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     224             : 
     225             :     rOutProperties.push_back(
     226             :         Property( "CrossoverValue",
     227             :                   PROP_AXIS_CROSSOVER_VALUE,
     228          11 :                   cppu::UnoType<double>::get(),
     229          11 :                   beans::PropertyAttribute::MAYBEVOID ));
     230             : 
     231             :     rOutProperties.push_back(
     232             :         Property( "Origin",
     233             :                   PROP_AXIS_ORIGIN,
     234          11 :                   cppu::UnoType<double>::get(),
     235             :                   beans::PropertyAttribute::BOUND
     236          22 :                   | beans::PropertyAttribute::MAYBEVOID ));
     237             : 
     238             :     rOutProperties.push_back(
     239             :         Property( "AutoOrigin",
     240             :                   PROP_AXIS_AUTO_ORIGIN,
     241          11 :                   cppu::UnoType<bool>::get(),
     242             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     243          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     244             : 
     245             :     //Properties for interval marks:
     246             :     rOutProperties.push_back(
     247             :         Property( "Marks",
     248             :                   PROP_AXIS_MARKS,
     249          11 :                   cppu::UnoType<sal_Int32>::get(),
     250             :                   beans::PropertyAttribute::BOUND
     251          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     252             : 
     253             :     rOutProperties.push_back(
     254             :         Property( "HelpMarks",
     255             :                   PROP_AXIS_HELPMARKS,
     256          11 :                   cppu::UnoType<sal_Int32>::get(),
     257             :                   beans::PropertyAttribute::BOUND
     258          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     259             : 
     260             :     rOutProperties.push_back(
     261             :         Property( "MarkPosition",
     262             :                   PROP_AXIS_MARK_POSITION,
     263          11 :                   cppu::UnoType<com::sun::star::chart::ChartAxisMarkPosition>::get(),
     264          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     265             : 
     266             :     //Properties for labels:
     267             :     rOutProperties.push_back(
     268             :         Property( "DisplayLabels",
     269             :                   PROP_AXIS_DISPLAY_LABELS,
     270          11 :                   cppu::UnoType<bool>::get(),
     271             :                   beans::PropertyAttribute::BOUND
     272          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     273             : 
     274             :     rOutProperties.push_back(
     275             :         Property( CHART_UNONAME_NUMFMT,
     276             :                   PROP_AXIS_NUMBERFORMAT,
     277          11 :                   cppu::UnoType<sal_Int32>::get(),
     278             :                   beans::PropertyAttribute::BOUND
     279          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     280             : 
     281             :     rOutProperties.push_back(
     282             :         Property( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
     283             :                   PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
     284          11 :                   cppu::UnoType<bool>::get(),
     285             :                   beans::PropertyAttribute::BOUND
     286          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     287             : 
     288             :     rOutProperties.push_back(
     289             :         Property( "LabelPosition",
     290             :                   PROP_AXIS_LABEL_POSITION,
     291          11 :                   cppu::UnoType<com::sun::star::chart::ChartAxisLabelPosition>::get(),
     292          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     293             : 
     294             :     rOutProperties.push_back(
     295             :         Property( "TextRotation",
     296             :                   PROP_AXIS_TEXT_ROTATION,
     297          11 :                   cppu::UnoType<sal_Int32>::get(),
     298             :                   beans::PropertyAttribute::BOUND
     299          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     300             : 
     301             :     rOutProperties.push_back(
     302             :         Property( "ArrangeOrder",
     303             :                   PROP_AXIS_ARRANGE_ORDER,
     304          11 :                   cppu::UnoType<com::sun::star::chart::ChartAxisArrangeOrderType>::get(),
     305             :                   beans::PropertyAttribute::BOUND
     306          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     307             : 
     308             :     rOutProperties.push_back(
     309             :         Property( "TextBreak",
     310             :                   PROP_AXIS_TEXTBREAK,
     311          11 :                   cppu::UnoType<bool>::get(),
     312             :                   beans::PropertyAttribute::BOUND
     313          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     314             : 
     315             :     rOutProperties.push_back(
     316             :         Property( "TextCanOverlap",
     317             :                   PROP_AXIS_CAN_OVERLAP,
     318          11 :                   cppu::UnoType<bool>::get(),
     319             :                   beans::PropertyAttribute::BOUND
     320          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     321             : 
     322             :     rOutProperties.push_back(
     323             :         Property( "StackedText",
     324             :                   PROP_AXIS_STACKEDTEXT,
     325          11 :                   cppu::UnoType<bool>::get(),
     326             :                   beans::PropertyAttribute::BOUND
     327          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     328             : 
     329             :     // Properties related to bar charts:
     330             :     rOutProperties.push_back(
     331             :         Property( "Overlap",
     332             :                   PROP_AXIS_OVERLAP,
     333          11 :                   cppu::UnoType<sal_Int32>::get(),
     334             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     335          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     336             : 
     337             :     rOutProperties.push_back(
     338             :         Property( "GapWidth",
     339             :                   PROP_AXIS_GAP_WIDTH,
     340          11 :                   cppu::UnoType<sal_Int32>::get(),
     341             :                   //#i111967# no PropertyChangeEvent is fired on change so far
     342          11 :                   beans::PropertyAttribute::MAYBEDEFAULT ));
     343             : 
     344             :     //Properties for display units:
     345             :     rOutProperties.push_back(
     346             :         Property( "DisplayUnits",
     347             :                   PROP_AXIS_DISPLAY_UNITS,
     348          11 :                   cppu::UnoType<bool>::get(),
     349             :                   beans::PropertyAttribute::BOUND
     350          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     351             : 
     352             :     //Properties for labels:
     353             :     rOutProperties.push_back(
     354             :         Property( "BuiltInUnit",
     355             :                   PROP_AXIS_BUILTINUNIT,
     356          11 :                   cppu::UnoType<OUString>::get(),
     357             :                   beans::PropertyAttribute::BOUND
     358          22 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
     359          11 : }
     360             : 
     361             : struct StaticAxisWrapperPropertyArray_Initializer
     362             : {
     363          11 :     Sequence< Property >* operator()()
     364             :     {
     365          11 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
     366          11 :         return &aPropSeq;
     367             :     }
     368             : 
     369             : private:
     370          11 :     static Sequence< Property > lcl_GetPropertySequence()
     371             :     {
     372          11 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
     373          11 :         lcl_AddPropertiesToVector( aProperties );
     374          11 :         ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
     375          11 :         ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
     376          11 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
     377          11 :         ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties );
     378             : 
     379             :         ::std::sort( aProperties.begin(), aProperties.end(),
     380          11 :                      ::chart::PropertyNameLess() );
     381             : 
     382          11 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
     383             :     }
     384             : };
     385             : 
     386             : struct StaticAxisWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAxisWrapperPropertyArray_Initializer >
     387             : {
     388             : };
     389             : 
     390             : } // anonymous namespace
     391             : 
     392             : namespace chart
     393             : {
     394             : namespace wrapper
     395             : {
     396             : 
     397         468 : AxisWrapper::AxisWrapper(
     398             :     tAxisType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
     399             :         m_spChart2ModelContact( spChart2ModelContact ),
     400             :         m_aEventListenerContainer( m_aMutex ),
     401         468 :         m_eType( eType )
     402             : {
     403         468 : }
     404             : 
     405         936 : AxisWrapper::~AxisWrapper()
     406             : {
     407         936 : }
     408             : 
     409             : // ____ chart::XAxis ____
     410         228 : Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getAxisTitle() throw (uno::RuntimeException, std::exception)
     411             : {
     412         228 :     if( !m_xAxisTitle.is() )
     413             :     {
     414          48 :         TitleHelper::eTitleType eTitleType( TitleHelper::X_AXIS_TITLE    );
     415          48 :         switch( m_eType )
     416             :         {
     417             :             case X_AXIS:
     418          20 :                 eTitleType = TitleHelper::X_AXIS_TITLE;
     419          20 :                 break;
     420             :             case Y_AXIS:
     421          24 :                 eTitleType = TitleHelper::Y_AXIS_TITLE;
     422          24 :                 break;
     423             :             case Z_AXIS:
     424           1 :                 eTitleType = TitleHelper::Z_AXIS_TITLE;
     425           1 :                 break;
     426             :             case SECOND_X_AXIS:
     427           0 :                 eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE;
     428           0 :                 break;
     429             :             case SECOND_Y_AXIS:
     430           3 :                 eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE;
     431           3 :                 break;
     432             :             default:
     433           0 :                 return 0;
     434             :         }
     435          48 :         m_xAxisTitle = new TitleWrapper( eTitleType, m_spChart2ModelContact );
     436             :     }
     437         228 :     return m_xAxisTitle;
     438             : }
     439         618 : Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMajorGrid() throw (uno::RuntimeException, std::exception)
     440             : {
     441         618 :     if( !m_xMajorGrid.is() )
     442             :     {
     443         187 :         GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID );
     444         187 :         switch( m_eType )
     445             :         {
     446             :             case X_AXIS:
     447          22 :                 eGridType = GridWrapper::X_MAJOR_GRID;
     448          22 :                 break;
     449             :             case Y_AXIS:
     450         164 :                 eGridType = GridWrapper::Y_MAJOR_GRID;
     451         164 :                 break;
     452             :             case Z_AXIS:
     453           1 :                 eGridType = GridWrapper::Z_MAJOR_GRID;
     454           1 :                 break;
     455             :             default:
     456           0 :                 return 0;
     457             :         }
     458         187 :         m_xMajorGrid = new GridWrapper( eGridType, m_spChart2ModelContact );
     459             :     }
     460         618 :     return m_xMajorGrid;
     461             : }
     462          85 : Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMinorGrid() throw (uno::RuntimeException, std::exception)
     463             : {
     464          85 :     if( !m_xMinorGrid.is() )
     465             :     {
     466          20 :         GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID );
     467          20 :         switch( m_eType )
     468             :         {
     469             :             case X_AXIS:
     470           1 :                 eGridType = GridWrapper::X_MINOR_GRID;
     471           1 :                 break;
     472             :             case Y_AXIS:
     473          18 :                 eGridType = GridWrapper::Y_MINOR_GRID;
     474          18 :                 break;
     475             :             case Z_AXIS:
     476           1 :                 eGridType = GridWrapper::Z_MINOR_GRID;
     477           1 :                 break;
     478             :             default:
     479           0 :                 return 0;
     480             :         }
     481          20 :         m_xMinorGrid = new GridWrapper( eGridType, m_spChart2ModelContact );
     482             :     }
     483          85 :     return m_xMinorGrid;
     484             : }
     485             : 
     486             : // ____ XShape ____
     487           0 : awt::Point SAL_CALL AxisWrapper::getPosition()
     488             :     throw (uno::RuntimeException, std::exception)
     489             : {
     490           0 :     awt::Point aResult( m_spChart2ModelContact->GetAxisPosition( this->getAxis() ) );
     491           0 :     return aResult;
     492             : }
     493             : 
     494           0 : void SAL_CALL AxisWrapper::setPosition( const awt::Point& /*aPosition*/ )
     495             :     throw (uno::RuntimeException, std::exception)
     496             : {
     497             :     OSL_FAIL( "trying to set position of Axis" );
     498           0 : }
     499             : 
     500           0 : awt::Size SAL_CALL AxisWrapper::getSize()
     501             :     throw (uno::RuntimeException, std::exception)
     502             : {
     503           0 :     awt::Size aSize( m_spChart2ModelContact->GetAxisSize( this->getAxis() ) );
     504           0 :     return aSize;
     505             : }
     506             : 
     507           0 : void SAL_CALL AxisWrapper::setSize( const awt::Size& /*aSize*/ )
     508             :     throw (beans::PropertyVetoException,
     509             :            uno::RuntimeException, std::exception)
     510             : {
     511             :     OSL_FAIL( "trying to set size of Axis" );
     512           0 : }
     513             : 
     514             : // ____ XShapeDescriptor (base of XShape) ____
     515           0 : OUString SAL_CALL AxisWrapper::getShapeType()
     516             :     throw (uno::RuntimeException, std::exception)
     517             : {
     518           0 :     return OUString("com.sun.star.chart.ChartAxis");
     519             : }
     520             : 
     521             : // ____ XNumberFormatsSupplier ____
     522           0 : uno::Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getNumberFormatSettings()
     523             :     throw (uno::RuntimeException, std::exception)
     524             : {
     525           0 :     Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
     526           0 :     if( xNumSuppl.is() )
     527           0 :         return xNumSuppl->getNumberFormatSettings();
     528             : 
     529           0 :     return uno::Reference< beans::XPropertySet >();
     530             : }
     531             : 
     532           0 : uno::Reference< util::XNumberFormats > SAL_CALL AxisWrapper::getNumberFormats()
     533             :     throw (uno::RuntimeException, std::exception)
     534             : {
     535           0 :     Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
     536           0 :     if( xNumSuppl.is() )
     537           0 :         return xNumSuppl->getNumberFormats();
     538             : 
     539           0 :     return uno::Reference< util::XNumberFormats >();
     540             : }
     541             : 
     542      168795 : void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, bool& rbMainAxis )
     543             : {
     544      168795 :     switch( eType )
     545             :     {
     546             :         case X_AXIS:
     547       68263 :             rnDimensionIndex = 0; rbMainAxis = true; break;
     548             :         case Y_AXIS:
     549       67984 :             rnDimensionIndex = 1; rbMainAxis = true; break;
     550             :         case Z_AXIS:
     551       22318 :             rnDimensionIndex = 2; rbMainAxis = true; break;
     552             :         case SECOND_X_AXIS:
     553        5069 :             rnDimensionIndex = 0; rbMainAxis = false; break;
     554             :         case SECOND_Y_AXIS:
     555        5161 :             rnDimensionIndex = 1; rbMainAxis = false; break;
     556             :     }
     557      168795 : }
     558             : 
     559             : // ____ XComponent ____
     560         466 : void SAL_CALL AxisWrapper::dispose()
     561             :     throw (uno::RuntimeException, std::exception)
     562             : {
     563         466 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     564         466 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
     565             : 
     566         466 :     DisposeHelper::DisposeAndClear( m_xAxisTitle );
     567         466 :     DisposeHelper::DisposeAndClear( m_xMajorGrid );
     568         466 :     DisposeHelper::DisposeAndClear( m_xMinorGrid );
     569             : 
     570         466 :     clearWrappedPropertySet();
     571         466 : }
     572             : 
     573           0 : void SAL_CALL AxisWrapper::addEventListener(
     574             :     const Reference< lang::XEventListener >& xListener )
     575             :     throw (uno::RuntimeException, std::exception)
     576             : {
     577           0 :     m_aEventListenerContainer.addInterface( xListener );
     578           0 : }
     579             : 
     580           0 : void SAL_CALL AxisWrapper::removeEventListener(
     581             :     const Reference< lang::XEventListener >& aListener )
     582             :     throw (uno::RuntimeException, std::exception)
     583             : {
     584           0 :     m_aEventListenerContainer.removeInterface( aListener );
     585           0 : }
     586             : 
     587             : //ReferenceSizePropertyProvider
     588         592 : void AxisWrapper::updateReferenceSize()
     589             : {
     590         592 :     Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY );
     591         592 :     if( xProp.is() )
     592             :     {
     593         592 :         if( xProp->getPropertyValue("ReferencePageSize").hasValue() )
     594           0 :             xProp->setPropertyValue("ReferencePageSize", uno::makeAny(
     595           0 :             m_spChart2ModelContact->GetPageSize() ));
     596         592 :     }
     597         592 : }
     598        4219 : Any AxisWrapper::getReferenceSize()
     599             : {
     600        4219 :     Any aRet;
     601        8438 :     Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY );
     602        4219 :     if( xProp.is() )
     603        4219 :         aRet = xProp->getPropertyValue("ReferencePageSize");
     604        8438 :     return aRet;
     605             : }
     606           0 : awt::Size AxisWrapper::getCurrentSizeForReference()
     607             : {
     608           0 :     return m_spChart2ModelContact->GetPageSize();
     609             : }
     610             : 
     611      168340 : Reference< chart2::XAxis > AxisWrapper::getAxis()
     612             : {
     613      168340 :     Reference< chart2::XAxis > xAxis;
     614             :     try
     615             :     {
     616      168340 :         sal_Int32 nDimensionIndex = 0;
     617      168340 :         bool  bMainAxis = true;
     618      168340 :         AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
     619             : 
     620      168340 :         Reference< XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
     621      168340 :         xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram );
     622      168340 :         if( !xAxis.is() )
     623             :         {
     624           0 :             xAxis = AxisHelper::createAxis( nDimensionIndex, bMainAxis, xDiagram, m_spChart2ModelContact->m_xContext );
     625           0 :             Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY );
     626           0 :             if( xProp.is() )
     627           0 :                 xProp->setPropertyValue("Show", uno::makeAny( sal_False ) );
     628      168340 :         }
     629             :     }
     630           0 :     catch( const uno::Exception & ex )
     631             :     {
     632             :         ASSERT_EXCEPTION( ex );
     633             :     }
     634      168340 :     return xAxis;
     635             : }
     636             : 
     637             : // WrappedPropertySet
     638      163529 : Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet()
     639             : {
     640      163529 :     return Reference< beans::XPropertySet >( this->getAxis(), uno::UNO_QUERY );
     641             : }
     642             : 
     643         455 : const Sequence< beans::Property >& AxisWrapper::getPropertySequence()
     644             : {
     645         455 :     return *StaticAxisWrapperPropertyArray::get();
     646             : }
     647             : 
     648         455 : const std::vector< WrappedProperty* > AxisWrapper::createWrappedProperties()
     649             : {
     650         455 :     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
     651             : 
     652         455 :     aWrappedProperties.push_back( new WrappedTextRotationProperty() );
     653         455 :     aWrappedProperties.push_back( new WrappedProperty("Marks","MajorTickmarks") );
     654         455 :     aWrappedProperties.push_back( new WrappedProperty("HelpMarks","MinorTickmarks") );
     655         455 :     aWrappedProperties.push_back( new WrappedProperty("TextCanOverlap","TextOverlap") );
     656         455 :     aWrappedProperties.push_back( new WrappedProperty("ArrangeOrder","ArrangeOrder") );
     657         455 :     aWrappedProperties.push_back( new WrappedProperty("Visible","Show") );
     658         455 :     aWrappedProperties.push_back( new WrappedDirectStateProperty("DisplayLabels","DisplayLabels") );
     659         455 :     aWrappedProperties.push_back( new WrappedDirectStateProperty("TextBreak","TextBreak") );
     660         455 :     aWrappedProperties.push_back( new WrappedNumberFormatProperty(m_spChart2ModelContact) );
     661         455 :     aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(m_spChart2ModelContact) );
     662         455 :     aWrappedProperties.push_back( new WrappedProperty("StackedText","StackCharacters") );
     663         455 :     aWrappedProperties.push_back( new WrappedDirectStateProperty("CrossoverPosition","CrossoverPosition") );
     664             :     {
     665         455 :         WrappedGapwidthProperty* pWrappedGapwidthProperty( new WrappedGapwidthProperty( m_spChart2ModelContact ) );
     666         455 :         WrappedBarOverlapProperty* pWrappedBarOverlapProperty( new WrappedBarOverlapProperty( m_spChart2ModelContact ) );
     667         455 :         sal_Int32 nDimensionIndex = 0;
     668         455 :         bool  bMainAxis = true;
     669         455 :         sal_Int32 nAxisIndex = 0;
     670         455 :         AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
     671         455 :         if( !bMainAxis )
     672          21 :             nAxisIndex = 1;
     673         455 :         pWrappedGapwidthProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
     674         455 :         pWrappedBarOverlapProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
     675         455 :         aWrappedProperties.push_back( pWrappedGapwidthProperty );
     676         455 :         aWrappedProperties.push_back( pWrappedBarOverlapProperty );
     677             :     }
     678             : 
     679         455 :     WrappedScaleProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
     680             : 
     681         455 :     WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
     682         455 :     WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
     683             : 
     684         455 :     return aWrappedProperties;
     685             : }
     686             : 
     687           3 : Sequence< OUString > AxisWrapper::getSupportedServiceNames_Static()
     688             : {
     689           3 :     Sequence< OUString > aServices( 3 );
     690           3 :     aServices[ 0 ] = "com.sun.star.chart.ChartAxis";
     691           3 :     aServices[ 1 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
     692           3 :     aServices[ 2 ] = "com.sun.star.style.CharacterProperties";
     693             : 
     694           3 :     return aServices;
     695             : }
     696             : 
     697             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     698           0 : OUString SAL_CALL AxisWrapper::getImplementationName()
     699             :     throw( css::uno::RuntimeException, std::exception )
     700             : {
     701           0 :     return getImplementationName_Static();
     702             : }
     703             : 
     704           0 : OUString AxisWrapper::getImplementationName_Static()
     705             : {
     706           0 :     return OUString(lcl_aServiceName);
     707             : }
     708             : 
     709           3 : sal_Bool SAL_CALL AxisWrapper::supportsService( const OUString& rServiceName )
     710             :     throw( css::uno::RuntimeException, std::exception )
     711             : {
     712           3 :     return cppu::supportsService(this, rServiceName);
     713             : }
     714             : 
     715           3 : css::uno::Sequence< OUString > SAL_CALL AxisWrapper::getSupportedServiceNames()
     716             :     throw( css::uno::RuntimeException, std::exception )
     717             : {
     718           3 :     return getSupportedServiceNames_Static();
     719             : }
     720             : 
     721             : } //  namespace wrapper
     722             : } //  namespace chart
     723             : 
     724             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11