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

Generated by: LCOV version 1.10