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

Generated by: LCOV version 1.10