LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - AreaWrapper.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 41 58 70.7 %
Date: 2014-04-11 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          15 : static const OUString lcl_aServiceName( "com.sun.star.comp.chart.Area" );
      44             : 
      45             : struct StaticAreaWrapperPropertyArray_Initializer
      46             : {
      47          10 :     Sequence< Property >* operator()()
      48             :     {
      49          10 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
      50          10 :         return &aPropSeq;
      51             :     }
      52             : 
      53             : private:
      54          10 :     Sequence< Property > lcl_GetPropertySequence()
      55             :     {
      56          10 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      57          10 :         ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
      58          10 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      59          10 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      60             : 
      61             :         ::std::sort( aProperties.begin(), aProperties.end(),
      62          10 :                      ::chart::PropertyNameLess() );
      63             : 
      64          10 :         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         143 : AreaWrapper::AreaWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
      80             :         m_spChart2ModelContact( spChart2ModelContact ),
      81         143 :         m_aEventListenerContainer( m_aMutex )
      82             : {
      83         143 : }
      84             : 
      85         280 : AreaWrapper::~AreaWrapper()
      86         280 : {}
      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         140 : void SAL_CALL AreaWrapper::dispose()
     123             :     throw (uno::RuntimeException, std::exception)
     124             : {
     125         140 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     126         140 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
     127             : 
     128         280 :     MutexGuard aGuard( GetMutex());
     129         280 :     clearWrappedPropertySet();
     130         140 : }
     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        9960 : Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet()
     148             : {
     149        9960 :     Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
     150        9960 :     if( xChartDoc.is() )
     151        9960 :         return xChartDoc->getPageBackground();
     152             :     OSL_FAIL("AreaWrapper::getInnerPropertySet() is NULL");
     153           0 :     return 0;
     154             : }
     155             : 
     156         142 : const Sequence< beans::Property >& AreaWrapper::getPropertySequence()
     157             : {
     158         142 :     return *StaticAreaWrapperPropertyArray::get();
     159             : }
     160             : 
     161         142 : const std::vector< WrappedProperty* > AreaWrapper::createWrappedProperties()
     162             : {
     163         142 :     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
     164             : 
     165         142 :     aWrappedProperties.push_back( new WrappedDirectStateProperty("LineStyle","LineStyle") );
     166             : 
     167         142 :     return aWrappedProperties;
     168             : }
     169             : 
     170           2 : Sequence< OUString > AreaWrapper::getSupportedServiceNames_Static()
     171             : {
     172           2 :     Sequence< OUString > aServices( 4 );
     173           2 :     aServices[ 0 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
     174           2 :     aServices[ 1 ] = "com.sun.star.beans.PropertySet";
     175           2 :     aServices[ 2 ] = "com.sun.star.drawing.FillProperties";
     176           2 :     aServices[ 3 ] = "com.sun.star.drawing.LineProperties";
     177             : 
     178           2 :     return aServices;
     179             : }
     180             : 
     181             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     182           4 : APPHELPER_XSERVICEINFO_IMPL( AreaWrapper, lcl_aServiceName );
     183             : 
     184             : } //  namespace wrapper
     185          45 : } //  namespace chart
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10