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

Generated by: LCOV version 1.10