LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/controller/chartapiwrapper - GridWrapper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 63 3.2 %
Date: 2012-12-27 Functions: 2 19 10.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "GridWrapper.hxx"
      22             : #include "macros.hxx"
      23             : #include "AxisHelper.hxx"
      24             : #include "Chart2ModelContact.hxx"
      25             : #include "ContainerHelper.hxx"
      26             : #include "AxisIndexDefines.hxx"
      27             : #include <comphelper/InlineContainer.hxx>
      28             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      29             : 
      30             : #include "LineProperties.hxx"
      31             : #include "UserDefinedProperties.hxx"
      32             : #include "WrappedDefaultProperty.hxx"
      33             : 
      34             : #include <algorithm>
      35             : #include <rtl/ustrbuf.hxx>
      36             : #include <rtl/math.hxx>
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using namespace ::com::sun::star::chart2;
      40             : 
      41             : using ::com::sun::star::beans::Property;
      42             : using ::osl::MutexGuard;
      43             : using ::com::sun::star::uno::Reference;
      44             : using ::com::sun::star::uno::Sequence;
      45             : using ::rtl::OUString;
      46             : 
      47             : namespace
      48             : {
      49           1 : static const OUString lcl_aServiceName(
      50             :     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Grid" ));
      51             : 
      52             : struct StaticGridWrapperPropertyArray_Initializer
      53             : {
      54           0 :     Sequence< Property >* operator()()
      55             :     {
      56           0 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
      57           0 :         return &aPropSeq;
      58             :     }
      59             : private:
      60           0 :     Sequence< Property > lcl_GetPropertySequence()
      61             :     {
      62           0 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      63           0 :         ::chart::LineProperties::AddPropertiesToVector( aProperties );
      64           0 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      65             : 
      66             :         ::std::sort( aProperties.begin(), aProperties.end(),
      67           0 :                      ::chart::PropertyNameLess() );
      68             : 
      69           0 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      70             :     }
      71             : };
      72             : 
      73             : struct StaticGridWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticGridWrapperPropertyArray_Initializer >
      74             : {
      75             : };
      76             : 
      77             : } // anonymous namespace
      78             : 
      79             : // --------------------------------------------------------------------------------
      80             : 
      81             : namespace chart
      82             : {
      83             : namespace wrapper
      84             : {
      85             : 
      86           0 : GridWrapper::GridWrapper(
      87             :     tGridType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
      88             :         m_spChart2ModelContact( spChart2ModelContact ),
      89             :         m_aEventListenerContainer( m_aMutex ),
      90           0 :         m_eType( eType )
      91             : {
      92           0 : }
      93             : 
      94           0 : GridWrapper::~GridWrapper()
      95           0 : {}
      96             : 
      97           0 : void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid )
      98             : {
      99           0 :     rnDimensionIndex = 1;
     100           0 :     rbSubGrid = false;
     101             : 
     102           0 :     switch( eType )
     103             :     {
     104             :         case X_MAJOR_GRID:
     105           0 :             rnDimensionIndex = 0; rbSubGrid = false; break;
     106             :         case Y_MAJOR_GRID:
     107           0 :             rnDimensionIndex = 1; rbSubGrid = false; break;
     108             :         case Z_MAJOR_GRID:
     109           0 :             rnDimensionIndex = 2; rbSubGrid = false; break;
     110             :         case X_MINOR_GRID:
     111           0 :             rnDimensionIndex = 0; rbSubGrid = true;  break;
     112             :         case Y_MINOR_GRID:
     113           0 :             rnDimensionIndex = 1; rbSubGrid = true;  break;
     114             :         case Z_MINOR_GRID:
     115           0 :             rnDimensionIndex = 2; rbSubGrid = true;  break;
     116             :     }
     117           0 : }
     118             : 
     119             : // ____ XComponent ____
     120           0 : void SAL_CALL GridWrapper::dispose()
     121             :     throw (uno::RuntimeException)
     122             : {
     123           0 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     124           0 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
     125             : 
     126           0 :     clearWrappedPropertySet();
     127           0 : }
     128             : 
     129           0 : void SAL_CALL GridWrapper::addEventListener(
     130             :     const Reference< lang::XEventListener >& xListener )
     131             :     throw (uno::RuntimeException)
     132             : {
     133           0 :     m_aEventListenerContainer.addInterface( xListener );
     134           0 : }
     135             : 
     136           0 : void SAL_CALL GridWrapper::removeEventListener(
     137             :     const Reference< lang::XEventListener >& aListener )
     138             :     throw (uno::RuntimeException)
     139             : {
     140           0 :     m_aEventListenerContainer.removeInterface( aListener );
     141           0 : }
     142             : 
     143             : // ================================================================================
     144             : 
     145             : // WrappedPropertySet
     146             : 
     147           0 : Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet()
     148             : {
     149           0 :     Reference< beans::XPropertySet > xRet;
     150             :     try
     151             :     {
     152           0 :         Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
     153           0 :         uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) );
     154             : 
     155           0 :         sal_Int32 nDimensionIndex = 1;
     156           0 :         bool bSubGrid = false;
     157           0 :         getDimensionAndSubGridBool( m_eType, nDimensionIndex, bSubGrid );
     158             : 
     159           0 :         sal_Int32 nSubGridIndex = bSubGrid ? 0 : -1;
     160           0 :         xRet.set( AxisHelper::getGridProperties( xCooSys , nDimensionIndex, MAIN_AXIS_INDEX, nSubGridIndex ) );
     161             :     }
     162           0 :     catch( const uno::Exception & ex )
     163             :     {
     164             :         ASSERT_EXCEPTION( ex );
     165             :     }
     166           0 :     return xRet;
     167             : }
     168             : 
     169           0 : const Sequence< beans::Property >& GridWrapper::getPropertySequence()
     170             : {
     171           0 :     return *StaticGridWrapperPropertyArray::get();
     172             : }
     173             : 
     174           0 : const std::vector< WrappedProperty* > GridWrapper::createWrappedProperties()
     175             : {
     176           0 :     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
     177             : 
     178           0 :     aWrappedProperties.push_back( new WrappedDefaultProperty( "LineColor", "LineColor", uno::makeAny( sal_Int32( 0x000000) ) ) ); // black
     179             : 
     180           0 :     return aWrappedProperties;
     181             : }
     182             : 
     183             : // ================================================================================
     184             : 
     185           0 : Sequence< OUString > GridWrapper::getSupportedServiceNames_Static()
     186             : {
     187           0 :     Sequence< OUString > aServices( 4 );
     188           0 :     aServices[ 0 ] = "com.sun.star.chart.ChartGrid";
     189           0 :     aServices[ 1 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
     190           0 :     aServices[ 2 ] = "com.sun.star.drawing.LineProperties";
     191           0 :     aServices[ 3 ] = "com.sun.star.beans.PropertySet";
     192             : 
     193           0 :     return aServices;
     194             : }
     195             : 
     196             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     197           0 : APPHELPER_XSERVICEINFO_IMPL( GridWrapper, lcl_aServiceName );
     198             : 
     199             : } //  namespace wrapper
     200           3 : } //  namespace chart
     201             : 
     202             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10