LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - GridWrapper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 63 0.0 %
Date: 2014-04-14 Functions: 0 19 0.0 %
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           0 : static const OUString lcl_aServiceName( "com.sun.star.comp.chart.Grid" );
      48             : 
      49             : struct StaticGridWrapperPropertyArray_Initializer
      50             : {
      51           0 :     Sequence< Property >* operator()()
      52             :     {
      53           0 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
      54           0 :         return &aPropSeq;
      55             :     }
      56             : private:
      57           0 :     Sequence< Property > lcl_GetPropertySequence()
      58             :     {
      59           0 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      60           0 :         ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
      61           0 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      62             : 
      63             :         ::std::sort( aProperties.begin(), aProperties.end(),
      64           0 :                      ::chart::PropertyNameLess() );
      65             : 
      66           0 :         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           0 : GridWrapper::GridWrapper(
      82             :     tGridType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
      83             :         m_spChart2ModelContact( spChart2ModelContact ),
      84             :         m_aEventListenerContainer( m_aMutex ),
      85           0 :         m_eType( eType )
      86             : {
      87           0 : }
      88             : 
      89           0 : GridWrapper::~GridWrapper()
      90           0 : {}
      91             : 
      92           0 : void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid )
      93             : {
      94           0 :     rnDimensionIndex = 1;
      95           0 :     rbSubGrid = false;
      96             : 
      97           0 :     switch( eType )
      98             :     {
      99             :         case X_MAJOR_GRID:
     100           0 :             rnDimensionIndex = 0; rbSubGrid = false; break;
     101             :         case Y_MAJOR_GRID:
     102           0 :             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           0 :             rnDimensionIndex = 1; rbSubGrid = true;  break;
     109             :         case Z_MINOR_GRID:
     110           0 :             rnDimensionIndex = 2; rbSubGrid = true;  break;
     111             :     }
     112           0 : }
     113             : 
     114             : // ____ XComponent ____
     115           0 : void SAL_CALL GridWrapper::dispose()
     116             :     throw (uno::RuntimeException, std::exception)
     117             : {
     118           0 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     119           0 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
     120             : 
     121           0 :     clearWrappedPropertySet();
     122           0 : }
     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           0 : Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet()
     141             : {
     142           0 :     Reference< beans::XPropertySet > xRet;
     143             :     try
     144             :     {
     145           0 :         Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
     146           0 :         uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) );
     147             : 
     148           0 :         sal_Int32 nDimensionIndex = 1;
     149           0 :         bool bSubGrid = false;
     150           0 :         getDimensionAndSubGridBool( m_eType, nDimensionIndex, bSubGrid );
     151             : 
     152           0 :         sal_Int32 nSubGridIndex = bSubGrid ? 0 : -1;
     153           0 :         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           0 :     return xRet;
     160             : }
     161             : 
     162           0 : const Sequence< beans::Property >& GridWrapper::getPropertySequence()
     163             : {
     164           0 :     return *StaticGridWrapperPropertyArray::get();
     165             : }
     166             : 
     167           0 : const std::vector< WrappedProperty* > GridWrapper::createWrappedProperties()
     168             : {
     169           0 :     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
     170             : 
     171           0 :     aWrappedProperties.push_back( new WrappedDefaultProperty( "LineColor", "LineColor", uno::makeAny( sal_Int32( 0x000000) ) ) ); // black
     172             : 
     173           0 :     return aWrappedProperties;
     174             : }
     175             : 
     176           0 : Sequence< OUString > GridWrapper::getSupportedServiceNames_Static()
     177             : {
     178           0 :     Sequence< OUString > aServices( 4 );
     179           0 :     aServices[ 0 ] = "com.sun.star.chart.ChartGrid";
     180           0 :     aServices[ 1 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
     181           0 :     aServices[ 2 ] = "com.sun.star.drawing.LineProperties";
     182           0 :     aServices[ 3 ] = "com.sun.star.beans.PropertySet";
     183             : 
     184           0 :     return aServices;
     185             : }
     186             : 
     187             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     188           0 : APPHELPER_XSERVICEINFO_IMPL( GridWrapper, lcl_aServiceName );
     189             : 
     190             : } //  namespace wrapper
     191           0 : } //  namespace chart
     192             : 
     193             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10