LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/controller/chartapiwrapper - WallFloorWrapper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 53 3.8 %
Date: 2012-12-27 Functions: 2 18 11.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             : 
      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           1 : static const OUString lcl_aServiceName(
      50             :     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.WallOrFloor" ));
      51             : 
      52             : struct StaticWallFloorWrapperPropertyArray_Initializer
      53             : {
      54           0 :     Sequence< Property >* operator()()
      55             :     {
      56           0 :         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
      57           0 :         return &aPropSeq;
      58             :     }
      59             : 
      60             : private:
      61           0 :     Sequence< Property > lcl_GetPropertySequence()
      62             :     {
      63           0 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      64           0 :         ::chart::FillProperties::AddPropertiesToVector( aProperties );
      65           0 :         ::chart::LineProperties::AddPropertiesToVector( aProperties );
      66           0 :         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
      67             : 
      68             :         ::std::sort( aProperties.begin(), aProperties.end(),
      69           0 :                      ::chart::PropertyNameLess() );
      70             : 
      71           0 :         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           0 : WallFloorWrapper::WallFloorWrapper( bool bWall,
      89             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
      90             :         m_spChart2ModelContact( spChart2ModelContact ),
      91             :         m_aEventListenerContainer( m_aMutex ),
      92           0 :         m_bWall( bWall )
      93             : 
      94             : {
      95           0 : }
      96             : 
      97           0 : WallFloorWrapper::~WallFloorWrapper()
      98             : {
      99           0 : }
     100             : 
     101             : // ____ XComponent ____
     102           0 : void SAL_CALL WallFloorWrapper::dispose()
     103             :     throw (uno::RuntimeException)
     104             : {
     105           0 :     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
     106           0 :     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
     107             : 
     108           0 :     MutexGuard aGuard( GetMutex());
     109           0 :     clearWrappedPropertySet();
     110           0 : }
     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           0 : Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet()
     130             : {
     131           0 :     Reference< beans::XPropertySet > xRet;
     132             : 
     133           0 :     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
     134           0 :     if( xDiagram.is() )
     135             :     {
     136           0 :         if( m_bWall )
     137           0 :             xRet.set( xDiagram->getWall() );
     138             :         else
     139           0 :             xRet.set( xDiagram->getFloor() );
     140             :     }
     141             : 
     142           0 :     return xRet;
     143             : }
     144             : 
     145           0 : const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence()
     146             : {
     147           0 :     return *StaticWallFloorWrapperPropertyArray::get();
     148             : }
     149             : 
     150           0 : const std::vector< WrappedProperty* > WallFloorWrapper::createWrappedProperties()
     151             : {
     152           0 :     ::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           0 :     if( m_bWall )
     158           0 :         aWrappedProperties.push_back( new WrappedDirectStateProperty( "FillStyle", "FillStyle" ));
     159           0 :     aWrappedProperties.push_back( new WrappedDirectStateProperty( "FillColor", "FillColor" ));
     160             : 
     161           0 :     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.UserDefinedAttributesSupplier";
     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           3 : } //  namespace chart
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10