LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - AreaWrapper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 42 63 66.7 %
Date: 2015-06-13 12:38:46 Functions: 12 21 57.1 %
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 "AreaWrapper.hxx"
      21             : #include "macros.hxx"
      22             : #include "ContainerHelper.hxx"
      23             : #include "Chart2ModelContact.hxx"
      24             : #include "WrappedDirectStateProperty.hxx"
      25             : #include <comphelper/InlineContainer.hxx>
      26             : #include <com/sun/star/drawing/FillStyle.hpp>
      27             : #include <cppuhelper/supportsservice.hxx>
      28             : 
      29             : #include "LinePropertiesHelper.hxx"
      30             : #include "FillProperties.hxx"
      31             : #include "UserDefinedProperties.hxx"
      32             : 
      33             : #include <algorithm>
      34             : 
      35             : using namespace ::com::sun::star;
      36             : using ::com::sun::star::beans::Property;
      37             : using ::osl::MutexGuard;
      38             : using ::com::sun::star::uno::Any;
      39             : using ::com::sun::star::uno::Reference;
      40             : using ::com::sun::star::uno::Sequence;
      41             : 
      42             : namespace
      43             : {
      44             : static const char lcl_aServiceName[] = "com.sun.star.comp.chart.Area";
      45             : 
      46             : struct StaticAreaWrapperPropertyArray_Initializer
      47             : {
      48          11 :     Sequence< Property >* operator()()
      49             :     {
      50          11 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
      51          11 :         return &aPropSeq;
      52             :     }
      53             : 
      54             : private:
      55          11 :     static Sequence< Property > lcl_GetPropertySequence()
      56             :     {
      57          11 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      58          11 :         ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
      59          11 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      60          11 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      61             : 
      62             :         ::std::sort( aProperties.begin(), aProperties.end(),
      63          11 :                      ::chart::PropertyNameLess() );
      64             : 
      65          11 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      66             :     }
      67             : };
      68             : 
      69             : struct StaticAreaWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAreaWrapperPropertyArray_Initializer >
      70             : {
      71             : };
      72             : 
      73             : } // anonymous namespace
      74             : 
      75             : namespace chart
      76             : {
      77             : namespace wrapper
      78             : {
      79             : 
      80         196 : AreaWrapper::AreaWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
      81             :         m_spChart2ModelContact( spChart2ModelContact ),
      82         196 :         m_aEventListenerContainer( m_aMutex )
      83             : {
      84         196 : }
      85             : 
      86         392 : AreaWrapper::~AreaWrapper()
      87         392 : {}
      88             : 
      89             : // ____ XShape ____
      90           0 : awt::Point SAL_CALL AreaWrapper::getPosition()
      91             :     throw (uno::RuntimeException, std::exception)
      92             : {
      93           0 :     return awt::Point(0,0);
      94             : }
      95             : 
      96           0 : void SAL_CALL AreaWrapper::setPosition( const awt::Point& /*aPosition*/ )
      97             :     throw (uno::RuntimeException, std::exception)
      98             : {
      99             :     OSL_FAIL( "trying to set position of chart area" );
     100           0 : }
     101             : 
     102           0 : awt::Size SAL_CALL AreaWrapper::getSize()
     103             :     throw (uno::RuntimeException, std::exception)
     104             : {
     105           0 :     return m_spChart2ModelContact->GetPageSize();
     106             : }
     107             : 
     108           0 : void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ )
     109             :     throw (beans::PropertyVetoException,
     110             :            uno::RuntimeException, std::exception)
     111             : {
     112             :     OSL_FAIL( "trying to set size of chart area" );
     113           0 : }
     114             : 
     115             : // ____ XShapeDescriptor (base of XShape) ____
     116           0 : OUString SAL_CALL AreaWrapper::getShapeType()
     117             :     throw (uno::RuntimeException, std::exception)
     118             : {
     119           0 :     return OUString( "com.sun.star.chart.ChartArea" );
     120             : }
     121             : 
     122             : // ____ XComponent ____
     123         196 : void SAL_CALL AreaWrapper::dispose()
     124             :     throw (uno::RuntimeException, std::exception)
     125             : {
     126         196 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     127         196 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
     128             : 
     129         392 :     MutexGuard aGuard( GetMutex());
     130         392 :     clearWrappedPropertySet();
     131         196 : }
     132             : 
     133           0 : void SAL_CALL AreaWrapper::addEventListener(
     134             :     const Reference< lang::XEventListener >& xListener )
     135             :     throw (uno::RuntimeException, std::exception)
     136             : {
     137           0 :     m_aEventListenerContainer.addInterface( xListener );
     138           0 : }
     139             : 
     140           0 : void SAL_CALL AreaWrapper::removeEventListener(
     141             :     const Reference< lang::XEventListener >& aListener )
     142             :     throw (uno::RuntimeException, std::exception)
     143             : {
     144           0 :     m_aEventListenerContainer.removeInterface( aListener );
     145           0 : }
     146             : 
     147             : // WrappedPropertySet
     148       15460 : Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet()
     149             : {
     150       15460 :     Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
     151       15460 :     if( xChartDoc.is() )
     152       15460 :         return xChartDoc->getPageBackground();
     153             :     OSL_FAIL("AreaWrapper::getInnerPropertySet() is NULL");
     154           0 :     return 0;
     155             : }
     156             : 
     157         195 : const Sequence< beans::Property >& AreaWrapper::getPropertySequence()
     158             : {
     159         195 :     return *StaticAreaWrapperPropertyArray::get();
     160             : }
     161             : 
     162         195 : const std::vector< WrappedProperty* > AreaWrapper::createWrappedProperties()
     163             : {
     164         195 :     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
     165             : 
     166         195 :     aWrappedProperties.push_back( new WrappedDirectStateProperty("LineStyle","LineStyle") );
     167             : 
     168         195 :     return aWrappedProperties;
     169             : }
     170             : 
     171           2 : Sequence< OUString > AreaWrapper::getSupportedServiceNames_Static()
     172             : {
     173           2 :     Sequence< OUString > aServices( 4 );
     174           2 :     aServices[ 0 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
     175           2 :     aServices[ 1 ] = "com.sun.star.beans.PropertySet";
     176           2 :     aServices[ 2 ] = "com.sun.star.drawing.FillProperties";
     177           2 :     aServices[ 3 ] = "com.sun.star.drawing.LineProperties";
     178             : 
     179           2 :     return aServices;
     180             : }
     181             : 
     182             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     183           0 : OUString SAL_CALL AreaWrapper::getImplementationName()
     184             :     throw( css::uno::RuntimeException, std::exception )
     185             : {
     186           0 :     return getImplementationName_Static();
     187             : }
     188             : 
     189           0 : OUString AreaWrapper::getImplementationName_Static()
     190             : {
     191           0 :     return OUString(lcl_aServiceName);
     192             : }
     193             : 
     194           2 : sal_Bool SAL_CALL AreaWrapper::supportsService( const OUString& rServiceName )
     195             :     throw( css::uno::RuntimeException, std::exception )
     196             : {
     197           2 :     return cppu::supportsService(this, rServiceName);
     198             : }
     199             : 
     200           2 : css::uno::Sequence< OUString > SAL_CALL AreaWrapper::getSupportedServiceNames()
     201             :     throw( css::uno::RuntimeException, std::exception )
     202             : {
     203           2 :     return getSupportedServiceNames_Static();
     204             : }
     205             : 
     206             : } //  namespace wrapper
     207             : } //  namespace chart
     208             : 
     209             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11