LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WallFloorWrapper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 39 53 73.6 %
Date: 2012-08-25 Functions: 11 18 61.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 42 100 42.0 %

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

Generated by: LCOV version 1.10