LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WallFloorWrapper.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 39 53 73.6 %
Date: 2014-11-03 Functions: 11 18 61.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 "WallFloorWrapper.hxx"
      21             : #include "macros.hxx"
      22             : #include "Chart2ModelContact.hxx"
      23             : #include "ContainerHelper.hxx"
      24             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      25             : #include <com/sun/star/drawing/FillStyle.hpp>
      26             : 
      27             : #include "FillProperties.hxx"
      28             : #include "LinePropertiesHelper.hxx"
      29             : #include "UserDefinedProperties.hxx"
      30             : #include "WrappedDirectStateProperty.hxx"
      31             : 
      32             : #include <algorithm>
      33             : #include <rtl/ustrbuf.hxx>
      34             : #include <rtl/math.hxx>
      35             : 
      36             : using namespace ::com::sun::star;
      37             : using namespace ::com::sun::star::chart2;
      38             : 
      39             : using ::com::sun::star::beans::Property;
      40             : using ::osl::MutexGuard;
      41             : using ::com::sun::star::uno::Any;
      42             : using ::com::sun::star::uno::Reference;
      43             : using ::com::sun::star::uno::Sequence;
      44             : 
      45             : namespace
      46             : {
      47          34 : static const OUString lcl_aServiceName( "com.sun.star.comp.chart.WallOrFloor" );
      48             : 
      49             : struct StaticWallFloorWrapperPropertyArray_Initializer
      50             : {
      51          24 :     Sequence< Property >* operator()()
      52             :     {
      53          24 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
      54          24 :         return &aPropSeq;
      55             :     }
      56             : 
      57             : private:
      58          24 :     Sequence< Property > lcl_GetPropertySequence()
      59             :     {
      60          24 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      61          24 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      62          24 :         ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
      63          24 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      64             : 
      65             :         ::std::sort( aProperties.begin(), aProperties.end(),
      66          24 :                      ::chart::PropertyNameLess() );
      67             : 
      68          24 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      69             :     }
      70             : };
      71             : 
      72             : struct StaticWallFloorWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticWallFloorWrapperPropertyArray_Initializer >
      73             : {
      74             : };
      75             : 
      76             : } // anonymous namespace
      77             : 
      78             : namespace chart
      79             : {
      80             : namespace wrapper
      81             : {
      82             : 
      83         854 : WallFloorWrapper::WallFloorWrapper( bool bWall,
      84             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
      85             :         m_spChart2ModelContact( spChart2ModelContact ),
      86             :         m_aEventListenerContainer( m_aMutex ),
      87         854 :         m_bWall( bWall )
      88             : 
      89             : {
      90         854 : }
      91             : 
      92        1708 : WallFloorWrapper::~WallFloorWrapper()
      93             : {
      94        1708 : }
      95             : 
      96             : // ____ XComponent ____
      97         850 : void SAL_CALL WallFloorWrapper::dispose()
      98             :     throw (uno::RuntimeException, std::exception)
      99             : {
     100         850 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     101         850 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
     102             : 
     103        1700 :     MutexGuard aGuard( GetMutex());
     104        1700 :     clearWrappedPropertySet();
     105         850 : }
     106             : 
     107           0 : void SAL_CALL WallFloorWrapper::addEventListener(
     108             :     const Reference< lang::XEventListener >& xListener )
     109             :     throw (uno::RuntimeException, std::exception)
     110             : {
     111           0 :     m_aEventListenerContainer.addInterface( xListener );
     112           0 : }
     113             : 
     114           0 : void SAL_CALL WallFloorWrapper::removeEventListener(
     115             :     const Reference< lang::XEventListener >& aListener )
     116             :     throw (uno::RuntimeException, std::exception)
     117             : {
     118           0 :     m_aEventListenerContainer.removeInterface( aListener );
     119           0 : }
     120             : 
     121             : // WrappedPropertySet
     122       65544 : Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet()
     123             : {
     124       65544 :     Reference< beans::XPropertySet > xRet;
     125             : 
     126      131088 :     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
     127       65544 :     if( xDiagram.is() )
     128             :     {
     129       63880 :         if( m_bWall )
     130       33012 :             xRet.set( xDiagram->getWall() );
     131             :         else
     132       30868 :             xRet.set( xDiagram->getFloor() );
     133             :     }
     134             : 
     135      131088 :     return xRet;
     136             : }
     137             : 
     138         852 : const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence()
     139             : {
     140         852 :     return *StaticWallFloorWrapperPropertyArray::get();
     141             : }
     142             : 
     143         852 : const std::vector< WrappedProperty* > WallFloorWrapper::createWrappedProperties()
     144             : {
     145         852 :     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
     146             : 
     147             :     // use direct state always, so that in XML the value is always
     148             :     // exported. Because in the old chart the defaults is as follows:
     149             :     // Floor: SOLID (new and old model default), Wall: NONE, except for some chart types (line, scatter)
     150         852 :     if( m_bWall )
     151         428 :         aWrappedProperties.push_back( new WrappedDirectStateProperty( "FillStyle", "FillStyle" ));
     152         852 :     aWrappedProperties.push_back( new WrappedDirectStateProperty( "FillColor", "FillColor" ));
     153             : 
     154         852 :     return aWrappedProperties;
     155             : }
     156             : 
     157           0 : Sequence< OUString > WallFloorWrapper::getSupportedServiceNames_Static()
     158             : {
     159           0 :     Sequence< OUString > aServices( 4 );
     160           0 :     aServices[ 0 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
     161           0 :     aServices[ 1 ] = "com.sun.star.drawing.FillProperties";
     162           0 :     aServices[ 2 ] = "com.sun.star.drawing.LineProperties";
     163           0 :     aServices[ 3 ] = "com.sun.star.beans.PropertySet";
     164             : 
     165           0 :     return aServices;
     166             : }
     167             : 
     168             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     169           0 : APPHELPER_XSERVICEINFO_IMPL( WallFloorWrapper, lcl_aServiceName );
     170             : 
     171             : } //  namespace wrapper
     172         102 : } //  namespace chart
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10