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

Generated by: LCOV version 1.10