LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WallFloorWrapper.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 39 53 73.6 %
Date: 2014-04-11 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          15 : static const OUString lcl_aServiceName( "com.sun.star.comp.chart.WallOrFloor" );
      48             : 
      49             : struct StaticWallFloorWrapperPropertyArray_Initializer
      50             : {
      51          10 :     Sequence< Property >* operator()()
      52             :     {
      53          10 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
      54          10 :         return &aPropSeq;
      55             :     }
      56             : 
      57             : private:
      58          10 :     Sequence< Property > lcl_GetPropertySequence()
      59             :     {
      60          10 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      61          10 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      62          10 :         ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
      63          10 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      64             : 
      65             :         ::std::sort( aProperties.begin(), aProperties.end(),
      66          10 :                      ::chart::PropertyNameLess() );
      67             : 
      68          10 :         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         283 : WallFloorWrapper::WallFloorWrapper( bool bWall,
      84             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
      85             :         m_spChart2ModelContact( spChart2ModelContact ),
      86             :         m_aEventListenerContainer( m_aMutex ),
      87         283 :         m_bWall( bWall )
      88             : 
      89             : {
      90         283 : }
      91             : 
      92         554 : WallFloorWrapper::~WallFloorWrapper()
      93             : {
      94         554 : }
      95             : 
      96             : // ____ XComponent ____
      97         275 : void SAL_CALL WallFloorWrapper::dispose()
      98             :     throw (uno::RuntimeException, std::exception)
      99             : {
     100         275 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     101         275 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
     102             : 
     103         550 :     MutexGuard aGuard( GetMutex());
     104         550 :     clearWrappedPropertySet();
     105         275 : }
     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       20712 : Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet()
     123             : {
     124       20712 :     Reference< beans::XPropertySet > xRet;
     125             : 
     126       41424 :     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
     127       20712 :     if( xDiagram.is() )
     128             :     {
     129       20712 :         if( m_bWall )
     130       10695 :             xRet.set( xDiagram->getWall() );
     131             :         else
     132       10017 :             xRet.set( xDiagram->getFloor() );
     133             :     }
     134             : 
     135       41424 :     return xRet;
     136             : }
     137             : 
     138         282 : const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence()
     139             : {
     140         282 :     return *StaticWallFloorWrapperPropertyArray::get();
     141             : }
     142             : 
     143         282 : const std::vector< WrappedProperty* > WallFloorWrapper::createWrappedProperties()
     144             : {
     145         282 :     ::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         282 :     if( m_bWall )
     151         142 :         aWrappedProperties.push_back( new WrappedDirectStateProperty( "FillStyle", "FillStyle" ));
     152         282 :     aWrappedProperties.push_back( new WrappedDirectStateProperty( "FillColor", "FillColor" ));
     153             : 
     154         282 :     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          45 : } //  namespace chart
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10