LCOV - code coverage report
Current view: top level - chart2/source/controller/itemsetwrapper - LegendItemConverter.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 62 0.0 %
Date: 2014-04-14 Functions: 0 9 0.0 %
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 "LegendItemConverter.hxx"
      21             : #include "SchWhichPairs.hxx"
      22             : #include "macros.hxx"
      23             : #include "ItemPropertyMap.hxx"
      24             : #include "GraphicPropertyItemConverter.hxx"
      25             : #include "CharacterPropertyItemConverter.hxx"
      26             : #include <com/sun/star/chart2/XLegend.hpp>
      27             : #include <com/sun/star/chart2/LegendPosition.hpp>
      28             : #include <com/sun/star/chart/ChartLegendExpansion.hpp>
      29             : 
      30             : #include <svl/intitem.hxx>
      31             : #include <svl/eitem.hxx>
      32             : 
      33             : #include <functional>
      34             : #include <algorithm>
      35             : 
      36             : using namespace ::com::sun::star;
      37             : 
      38             : namespace chart
      39             : {
      40             : namespace wrapper
      41             : {
      42             : 
      43             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
      44           0 : LegendItemConverter::LegendItemConverter(
      45             :     const ::com::sun::star::uno::Reference<
      46             :     ::com::sun::star::beans::XPropertySet > & rPropertySet,
      47             :     SfxItemPool& rItemPool,
      48             :     SdrModel& rDrawModel,
      49             :     const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
      50             :     ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize ) :
      51           0 :         ItemConverter( rPropertySet, rItemPool )
      52             : {
      53             :     m_aConverters.push_back( new GraphicPropertyItemConverter(
      54             :                                  rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
      55           0 :                                  GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ));
      56             :     m_aConverters.push_back( new CharacterPropertyItemConverter(
      57             :                                  rPropertySet, rItemPool, pRefSize,
      58           0 :                                  "ReferencePageSize" ));
      59           0 : }
      60             : SAL_WNODEPRECATED_DECLARATIONS_POP
      61             : 
      62           0 : LegendItemConverter::~LegendItemConverter()
      63             : {
      64             :     ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
      65           0 :                      ::comphelper::DeleteItemConverterPtr() );
      66           0 : }
      67             : 
      68           0 : void LegendItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
      69             : {
      70             :     ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
      71           0 :                      ::comphelper::FillItemSetFunc( rOutItemSet ));
      72             : 
      73             :     // own items
      74           0 :     ItemConverter::FillItemSet( rOutItemSet );
      75           0 : }
      76             : 
      77           0 : bool LegendItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
      78             : {
      79           0 :     bool bResult = false;
      80             : 
      81             :     ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
      82           0 :                      ::comphelper::ApplyItemSetFunc( rItemSet, bResult ));
      83             : 
      84             :     // own items
      85           0 :     return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
      86             : }
      87             : 
      88           0 : const sal_uInt16 * LegendItemConverter::GetWhichPairs() const
      89             : {
      90             :     // must span all used items!
      91           0 :     return nLegendWhichPairs;
      92             : }
      93             : 
      94           0 : bool LegendItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyNameWithMemberId & /*rOutProperty*/ ) const
      95             : {
      96             :     // No own (non-special) properties
      97           0 :     return false;
      98             : }
      99             : 
     100           0 : bool LegendItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet& rInItemSet )
     101             :     throw( uno::Exception )
     102             : {
     103           0 :     bool bChanged = false;
     104             : 
     105           0 :     switch( nWhichId )
     106             :     {
     107             :         case SCHATTR_LEGEND_SHOW:
     108             :         {
     109           0 :             const SfxPoolItem* pPoolItem = NULL;
     110           0 :             if( rInItemSet.GetItemState( SCHATTR_LEGEND_SHOW, true, &pPoolItem ) == SFX_ITEM_SET )
     111             :             {
     112           0 :                 sal_Bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
     113           0 :                 sal_Bool bWasShown = sal_True;
     114           0 :                 if( ! (GetPropertySet()->getPropertyValue( "Show" ) >>= bWasShown) ||
     115           0 :                     ( bWasShown != bShow ))
     116             :                 {
     117           0 :                     GetPropertySet()->setPropertyValue( "Show" , uno::makeAny( bShow ));
     118           0 :                     bChanged = true;
     119             :                 }
     120             :             }
     121             : 
     122             :         }
     123           0 :         break;
     124             :         case SCHATTR_LEGEND_POS:
     125             :         {
     126           0 :             const SfxPoolItem* pPoolItem = NULL;
     127           0 :             if( rInItemSet.GetItemState( SCHATTR_LEGEND_POS, true, &pPoolItem ) == SFX_ITEM_SET )
     128             :             {
     129           0 :                 chart2::LegendPosition eNewPos = static_cast<chart2::LegendPosition>(((const SfxInt32Item*)pPoolItem)->GetValue());
     130             : 
     131           0 :                 ::com::sun::star::chart::ChartLegendExpansion eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
     132           0 :                 switch( eNewPos )
     133             :                 {
     134             :                     case chart2::LegendPosition_LINE_START:
     135             :                     case chart2::LegendPosition_LINE_END:
     136           0 :                         eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
     137           0 :                         break;
     138             :                     case chart2::LegendPosition_PAGE_START:
     139             :                     case chart2::LegendPosition_PAGE_END:
     140           0 :                         eExpansion = ::com::sun::star::chart::ChartLegendExpansion_WIDE;
     141           0 :                         break;
     142             :                     default:
     143           0 :                         break;
     144             :                 }
     145             : 
     146             :                 try
     147             :                 {
     148             :                     chart2::LegendPosition eOldPos;
     149           0 :                     if( ! ( GetPropertySet()->getPropertyValue( "AnchorPosition" ) >>= eOldPos ) ||
     150           0 :                         ( eOldPos != eNewPos ))
     151             :                     {
     152           0 :                         GetPropertySet()->setPropertyValue( "AnchorPosition" , uno::makeAny( eNewPos ));
     153           0 :                         GetPropertySet()->setPropertyValue( "Expansion" , uno::makeAny( eExpansion ));
     154           0 :                         GetPropertySet()->setPropertyValue( "RelativePosition" , uno::Any());
     155           0 :                         bChanged = true;
     156             :                     }
     157             :                 }
     158           0 :                 catch( const uno::Exception & ex )
     159             :                 {
     160             :                     ASSERT_EXCEPTION( ex );
     161             :                 }
     162             :             }
     163             :         }
     164           0 :         break;
     165             :     }
     166             : 
     167           0 :     return bChanged;
     168             : }
     169             : 
     170           0 : void LegendItemConverter::FillSpecialItem(
     171             :     sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
     172             :     throw( uno::Exception )
     173             : {
     174           0 :     switch( nWhichId )
     175             :     {
     176             :         case SCHATTR_LEGEND_SHOW:
     177             :         {
     178           0 :             sal_Bool bShow = sal_True;
     179           0 :             GetPropertySet()->getPropertyValue( "Show" ) >>= bShow;
     180           0 :             rOutItemSet.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, bShow) );
     181             :         }
     182           0 :         break;
     183             :         case SCHATTR_LEGEND_POS:
     184             :         {
     185           0 :             chart2::LegendPosition eLegendPos( chart2::LegendPosition_LINE_END );
     186           0 :             GetPropertySet()->getPropertyValue( "AnchorPosition" ) >>= eLegendPos;
     187           0 :             rOutItemSet.Put( SfxInt32Item(SCHATTR_LEGEND_POS, eLegendPos ) );
     188             :         }
     189           0 :         break;
     190             :    }
     191           0 : }
     192             : 
     193             : } //  namespace wrapper
     194             : } //  namespace chart
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10