LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - GridWrapper.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 53 63 84.1 %
Date: 2014-11-03 Functions: 15 19 78.9 %
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 "GridWrapper.hxx"
      21             : #include "macros.hxx"
      22             : #include "AxisHelper.hxx"
      23             : #include "Chart2ModelContact.hxx"
      24             : #include "ContainerHelper.hxx"
      25             : #include "AxisIndexDefines.hxx"
      26             : #include <comphelper/InlineContainer.hxx>
      27             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28             : 
      29             : #include "LinePropertiesHelper.hxx"
      30             : #include "UserDefinedProperties.hxx"
      31             : #include "WrappedDefaultProperty.hxx"
      32             : 
      33             : #include <algorithm>
      34             : #include <rtl/ustrbuf.hxx>
      35             : #include <rtl/math.hxx>
      36             : 
      37             : using namespace ::com::sun::star;
      38             : using namespace ::com::sun::star::chart2;
      39             : 
      40             : using ::com::sun::star::beans::Property;
      41             : using ::osl::MutexGuard;
      42             : using ::com::sun::star::uno::Reference;
      43             : using ::com::sun::star::uno::Sequence;
      44             : 
      45             : namespace
      46             : {
      47          34 : static const OUString lcl_aServiceName( "com.sun.star.comp.chart.Grid" );
      48             : 
      49             : struct StaticGridWrapperPropertyArray_Initializer
      50             : {
      51          18 :     Sequence< Property >* operator()()
      52             :     {
      53          18 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
      54          18 :         return &aPropSeq;
      55             :     }
      56             : private:
      57          18 :     Sequence< Property > lcl_GetPropertySequence()
      58             :     {
      59          18 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      60          18 :         ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
      61          18 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      62             : 
      63             :         ::std::sort( aProperties.begin(), aProperties.end(),
      64          18 :                      ::chart::PropertyNameLess() );
      65             : 
      66          18 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      67             :     }
      68             : };
      69             : 
      70             : struct StaticGridWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticGridWrapperPropertyArray_Initializer >
      71             : {
      72             : };
      73             : 
      74             : } // anonymous namespace
      75             : 
      76             : namespace chart
      77             : {
      78             : namespace wrapper
      79             : {
      80             : 
      81         452 : GridWrapper::GridWrapper(
      82             :     tGridType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
      83             :         m_spChart2ModelContact( spChart2ModelContact ),
      84             :         m_aEventListenerContainer( m_aMutex ),
      85         452 :         m_eType( eType )
      86             : {
      87         452 : }
      88             : 
      89         904 : GridWrapper::~GridWrapper()
      90         904 : {}
      91             : 
      92       12220 : void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid )
      93             : {
      94       12220 :     rnDimensionIndex = 1;
      95       12220 :     rbSubGrid = false;
      96             : 
      97       12220 :     switch( eType )
      98             :     {
      99             :         case X_MAJOR_GRID:
     100        1382 :             rnDimensionIndex = 0; rbSubGrid = false; break;
     101             :         case Y_MAJOR_GRID:
     102        9246 :             rnDimensionIndex = 1; rbSubGrid = false; break;
     103             :         case Z_MAJOR_GRID:
     104           0 :             rnDimensionIndex = 2; rbSubGrid = false; break;
     105             :         case X_MINOR_GRID:
     106           0 :             rnDimensionIndex = 0; rbSubGrid = true;  break;
     107             :         case Y_MINOR_GRID:
     108        1592 :             rnDimensionIndex = 1; rbSubGrid = true;  break;
     109             :         case Z_MINOR_GRID:
     110           0 :             rnDimensionIndex = 2; rbSubGrid = true;  break;
     111             :     }
     112       12220 : }
     113             : 
     114             : // ____ XComponent ____
     115         448 : void SAL_CALL GridWrapper::dispose()
     116             :     throw (uno::RuntimeException, std::exception)
     117             : {
     118         448 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     119         448 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
     120             : 
     121         448 :     clearWrappedPropertySet();
     122         448 : }
     123             : 
     124           0 : void SAL_CALL GridWrapper::addEventListener(
     125             :     const Reference< lang::XEventListener >& xListener )
     126             :     throw (uno::RuntimeException, std::exception)
     127             : {
     128           0 :     m_aEventListenerContainer.addInterface( xListener );
     129           0 : }
     130             : 
     131           0 : void SAL_CALL GridWrapper::removeEventListener(
     132             :     const Reference< lang::XEventListener >& aListener )
     133             :     throw (uno::RuntimeException, std::exception)
     134             : {
     135           0 :     m_aEventListenerContainer.removeInterface( aListener );
     136           0 : }
     137             : 
     138             : // WrappedPropertySet
     139             : 
     140       12220 : Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet()
     141             : {
     142       12220 :     Reference< beans::XPropertySet > xRet;
     143             :     try
     144             :     {
     145       12220 :         Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
     146       24440 :         uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) );
     147             : 
     148       12220 :         sal_Int32 nDimensionIndex = 1;
     149       12220 :         bool bSubGrid = false;
     150       12220 :         getDimensionAndSubGridBool( m_eType, nDimensionIndex, bSubGrid );
     151             : 
     152       12220 :         sal_Int32 nSubGridIndex = bSubGrid ? 0 : -1;
     153       24440 :         xRet.set( AxisHelper::getGridProperties( xCooSys , nDimensionIndex, MAIN_AXIS_INDEX, nSubGridIndex ) );
     154             :     }
     155           0 :     catch( const uno::Exception & ex )
     156             :     {
     157             :         ASSERT_EXCEPTION( ex );
     158             :     }
     159       12220 :     return xRet;
     160             : }
     161             : 
     162         440 : const Sequence< beans::Property >& GridWrapper::getPropertySequence()
     163             : {
     164         440 :     return *StaticGridWrapperPropertyArray::get();
     165             : }
     166             : 
     167         440 : const std::vector< WrappedProperty* > GridWrapper::createWrappedProperties()
     168             : {
     169         440 :     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
     170             : 
     171         440 :     aWrappedProperties.push_back( new WrappedDefaultProperty( "LineColor", "LineColor", uno::makeAny( sal_Int32( 0x000000) ) ) ); // black
     172             : 
     173         440 :     return aWrappedProperties;
     174             : }
     175             : 
     176           2 : Sequence< OUString > GridWrapper::getSupportedServiceNames_Static()
     177             : {
     178           2 :     Sequence< OUString > aServices( 4 );
     179           2 :     aServices[ 0 ] = "com.sun.star.chart.ChartGrid";
     180           2 :     aServices[ 1 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
     181           2 :     aServices[ 2 ] = "com.sun.star.drawing.LineProperties";
     182           2 :     aServices[ 3 ] = "com.sun.star.beans.PropertySet";
     183             : 
     184           2 :     return aServices;
     185             : }
     186             : 
     187             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     188           4 : APPHELPER_XSERVICEINFO_IMPL( GridWrapper, lcl_aServiceName );
     189             : 
     190             : } //  namespace wrapper
     191         102 : } //  namespace chart
     192             : 
     193             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10