LCOV - code coverage report
Current view: top level - chart2/source/controller/itemsetwrapper - DataPointItemConverter.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 296 0.3 %
Date: 2014-11-03 Functions: 2 15 13.3 %
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 "DataPointItemConverter.hxx"
      21             : #include "SchWhichPairs.hxx"
      22             : #include "macros.hxx"
      23             : #include "ItemPropertyMap.hxx"
      24             : 
      25             : #include "GraphicPropertyItemConverter.hxx"
      26             : #include "CharacterPropertyItemConverter.hxx"
      27             : #include "StatisticsItemConverter.hxx"
      28             : #include "SeriesOptionsItemConverter.hxx"
      29             : #include "DataSeriesHelper.hxx"
      30             : #include "DiagramHelper.hxx"
      31             : #include "ChartModelHelper.hxx"
      32             : #include "ChartTypeHelper.hxx"
      33             : #include <unonames.hxx>
      34             : 
      35             : #include <svx/chrtitem.hxx>
      36             : #include <com/sun/star/chart2/DataPointLabel.hpp>
      37             : #include <com/sun/star/chart2/Symbol.hpp>
      38             : 
      39             : #include <svx/xflclit.hxx>
      40             : #include <svl/intitem.hxx>
      41             : #include <editeng/sizeitem.hxx>
      42             : #include <svl/stritem.hxx>
      43             : #include <editeng/brushitem.hxx>
      44             : #include <svl/ilstitem.hxx>
      45             : #include <vcl/graph.hxx>
      46             : #include <com/sun/star/graphic/XGraphic.hpp>
      47             : 
      48             : #include <svx/tabline.hxx>
      49             : 
      50             : #include <functional>
      51             : #include <algorithm>
      52             : 
      53             : using namespace ::com::sun::star;
      54             : using namespace ::com::sun::star::chart2;
      55             : using ::com::sun::star::uno::Reference;
      56             : 
      57             : namespace chart { namespace wrapper {
      58             : 
      59             : namespace {
      60             : 
      61           0 : ItemPropertyMapType & lcl_GetDataPointPropertyMap()
      62             : {
      63             :     static ItemPropertyMapType aDataPointPropertyMap(
      64             :         MakeItemPropertyMap
      65             :         IPM_MAP_ENTRY( SCHATTR_STYLE_SHAPE, "Geometry3D", 0 )
      66           0 :         );
      67             : 
      68           0 :     return aDataPointPropertyMap;
      69             : };
      70             : 
      71           0 : sal_Int32 lcl_getSymbolStyleForSymbol( const chart2::Symbol & rSymbol )
      72             : {
      73           0 :     sal_Int32 nStyle = SVX_SYMBOLTYPE_UNKNOWN;
      74           0 :     switch( rSymbol.Style )
      75             :     {
      76             :         case chart2::SymbolStyle_NONE:
      77           0 :             nStyle = SVX_SYMBOLTYPE_NONE;
      78           0 :             break;
      79             :         case chart2::SymbolStyle_AUTO:
      80           0 :             nStyle = SVX_SYMBOLTYPE_AUTO;
      81           0 :             break;
      82             :         case chart2::SymbolStyle_GRAPHIC:
      83           0 :             nStyle = SVX_SYMBOLTYPE_BRUSHITEM;
      84           0 :             break;
      85             :         case chart2::SymbolStyle_STANDARD:
      86           0 :             nStyle = rSymbol.StandardSymbol;
      87           0 :             break;
      88             : 
      89             :         case chart2::SymbolStyle_POLYGON:
      90             :             // to avoid warning
      91             :         case chart2::SymbolStyle_MAKE_FIXED_SIZE:
      92             :             // nothing
      93           0 :             break;
      94             :     }
      95           0 :     return nStyle;
      96             : }
      97             : 
      98           0 : bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso  )
      99             : {
     100           0 :     bool bChanged = false;
     101           0 :     if( !xPropertySet.is() )
     102           0 :         return bChanged;
     103           0 :     OUString aPropertyName = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? OUString(CHART_UNONAME_NUMFMT) : OUString( "PercentageNumberFormat" );
     104           0 :     sal_uInt16 nSourceWhich = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE;
     105             : 
     106           0 :     if( SfxItemState::SET != rItemSet.GetItemState( nSourceWhich ) )
     107           0 :         return bChanged;
     108             : 
     109           0 :     uno::Any aValue;
     110             :     bool bUseSourceFormat = (static_cast< const SfxBoolItem & >(
     111           0 :                 rItemSet.Get( nSourceWhich )).GetValue() );
     112           0 :     if( !bUseSourceFormat )
     113             :     {
     114           0 :         SfxItemState aState = rItemSet.GetItemState( nWhichId );
     115           0 :         if( aState == SfxItemState::SET )
     116             :         {
     117             :             sal_Int32 nFmt = static_cast< sal_Int32 >(
     118             :                 static_cast< const SfxUInt32Item & >(
     119           0 :                     rItemSet.Get( nWhichId )).GetValue());
     120           0 :             aValue = uno::makeAny(nFmt);
     121             :         }
     122             :         else
     123           0 :             return bChanged;
     124             :     }
     125             : 
     126           0 :     uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
     127           0 :     if( bOverwriteAttributedDataPointsAlso )
     128             :     {
     129           0 :         Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY);
     130           0 :         if( aValue != aOldValue ||
     131           0 :             ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
     132             :         {
     133           0 :             ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aValue );
     134           0 :             bChanged = true;
     135           0 :         }
     136             :     }
     137           0 :     else if( aOldValue != aValue )
     138             :     {
     139           0 :         xPropertySet->setPropertyValue(aPropertyName, aValue );
     140           0 :         bChanged = true;
     141             :     }
     142           0 :     return bChanged;
     143             : }
     144             : 
     145           0 : bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso  )
     146             : {
     147           0 :     bool bChanged = false;
     148           0 :     if( !xPropertySet.is() )
     149           0 :         return bChanged;
     150           0 :     OUString aPropertyName = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? OUString(CHART_UNONAME_NUMFMT) : OUString( "PercentageNumberFormat" );
     151           0 :     sal_uInt16 nFormatWhich = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE;
     152             : 
     153           0 :     if( SfxItemState::SET != rItemSet.GetItemState( nWhichId ) )
     154           0 :         return bChanged;
     155             : 
     156           0 :     uno::Any aNewValue;
     157             :     bool bUseSourceFormat = (static_cast< const SfxBoolItem & >(
     158           0 :                 rItemSet.Get( nWhichId )).GetValue() );
     159           0 :     if( !bUseSourceFormat )
     160             :     {
     161           0 :         SfxItemState aState = rItemSet.GetItemState( nFormatWhich );
     162           0 :         if( aState == SfxItemState::SET )
     163             :         {
     164             :             sal_Int32 nFormatKey = static_cast< sal_Int32 >(
     165             :             static_cast< const SfxUInt32Item & >(
     166           0 :                 rItemSet.Get( nFormatWhich )).GetValue());
     167           0 :             aNewValue <<= nFormatKey;
     168             :         }
     169             :         else
     170           0 :             return bChanged;
     171             :     }
     172             : 
     173           0 :     uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
     174           0 :     if( bOverwriteAttributedDataPointsAlso )
     175             :     {
     176           0 :         Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY);
     177           0 :         if( aNewValue != aOldValue ||
     178           0 :             ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
     179             :         {
     180           0 :             ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aNewValue );
     181           0 :             bChanged = true;
     182           0 :         }
     183             :     }
     184           0 :     else if( aOldValue != aNewValue )
     185             :     {
     186           0 :         xPropertySet->setPropertyValue( aPropertyName, aNewValue );
     187           0 :         bChanged = true;
     188             :     }
     189             : 
     190           0 :     return bChanged;
     191             : }
     192             : 
     193             : } // anonymous namespace
     194             : 
     195           0 : DataPointItemConverter::DataPointItemConverter(
     196             :     const uno::Reference< frame::XModel > & xChartModel,
     197             :     const uno::Reference< uno::XComponentContext > & xContext,
     198             :     const uno::Reference< beans::XPropertySet > & rPropertySet,
     199             :     const uno::Reference< XDataSeries > & xSeries,
     200             :     SfxItemPool& rItemPool,
     201             :     SdrModel& rDrawModel,
     202             :     const uno::Reference<lang::XMultiServiceFactory>& xNamedPropertyContainerFactory,
     203             :     GraphicPropertyItemConverter::eGraphicObjectType eMapTo,
     204             :     const awt::Size* pRefSize,
     205             :     bool bDataSeries,
     206             :     bool bUseSpecialFillColor,
     207             :     sal_Int32 nSpecialFillColor,
     208             :     bool bOverwriteLabelsForAttributedDataPointsAlso,
     209             :     sal_Int32 nNumberFormat,
     210             :     sal_Int32 nPercentNumberFormat ) :
     211             :         ItemConverter( rPropertySet, rItemPool ),
     212             :         m_bDataSeries( bDataSeries ),
     213           0 :         m_bOverwriteLabelsForAttributedDataPointsAlso(m_bDataSeries && bOverwriteLabelsForAttributedDataPointsAlso),
     214             :         m_bUseSpecialFillColor(bUseSpecialFillColor),
     215             :         m_nSpecialFillColor(nSpecialFillColor),
     216             :         m_nNumberFormat(nNumberFormat),
     217             :         m_nPercentNumberFormat(nPercentNumberFormat),
     218             :         m_aAvailableLabelPlacements(),
     219           0 :         m_bForbidPercentValue(true)
     220             : {
     221             :     m_aConverters.push_back( new GraphicPropertyItemConverter(
     222           0 :                                  rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, eMapTo ));
     223           0 :     m_aConverters.push_back( new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize"));
     224           0 :     if( bDataSeries )
     225             :     {
     226           0 :         m_aConverters.push_back( new StatisticsItemConverter( xChartModel, rPropertySet, rItemPool ));
     227           0 :         m_aConverters.push_back( new SeriesOptionsItemConverter( xChartModel, xContext, rPropertySet, rItemPool ));
     228             :     }
     229             : 
     230           0 :     uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) );
     231           0 :     uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xSeries ) );
     232           0 :     bool bFound = false;
     233           0 :     bool bAmbiguous = false;
     234           0 :     bool bSwapXAndY = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
     235           0 :     m_aAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements( xChartType, DiagramHelper::getDimension( xDiagram ), bSwapXAndY, xSeries );
     236             : 
     237           0 :     m_bForbidPercentValue = AxisType::CATEGORY != ChartTypeHelper::getAxisType( xChartType, 0 );
     238           0 : }
     239             : 
     240           0 : DataPointItemConverter::~DataPointItemConverter()
     241             : {
     242           0 :     ::std::for_each(m_aConverters.begin(), m_aConverters.end(), boost::checked_deleter<ItemConverter>());
     243           0 : }
     244             : 
     245           0 : void DataPointItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
     246             : {
     247             :     ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
     248           0 :                      FillItemSetFunc( rOutItemSet ));
     249             : 
     250             :     // own items
     251           0 :     ItemConverter::FillItemSet( rOutItemSet );
     252             : 
     253           0 :     if( m_bUseSpecialFillColor )
     254             :     {
     255           0 :         Color aColor(m_nSpecialFillColor);
     256           0 :         rOutItemSet.Put( XFillColorItem( OUString(), aColor ) );
     257             :     }
     258           0 : }
     259             : 
     260           0 : bool DataPointItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
     261             : {
     262           0 :     bool bResult = false;
     263             : 
     264             :     ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
     265           0 :                      ApplyItemSetFunc( rItemSet, bResult ));
     266             : 
     267             :     // own items
     268           0 :     return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
     269             : }
     270             : 
     271           0 : const sal_uInt16 * DataPointItemConverter::GetWhichPairs() const
     272             : {
     273             :     // must span all used items!
     274           0 :     if( m_bDataSeries )
     275           0 :         return nRowWhichPairs;
     276           0 :     return nDataPointWhichPairs;
     277             : }
     278             : 
     279           0 : bool DataPointItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
     280             : {
     281           0 :     ItemPropertyMapType & rMap( lcl_GetDataPointPropertyMap());
     282           0 :     ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
     283             : 
     284           0 :     if( aIt == rMap.end())
     285           0 :         return false;
     286             : 
     287           0 :     rOutProperty =(*aIt).second;
     288           0 :     return true;
     289             : }
     290             : 
     291           0 : bool DataPointItemConverter::ApplySpecialItem(
     292             :     sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
     293             :     throw( uno::Exception )
     294             : {
     295           0 :     bool bChanged = false;
     296             : 
     297           0 :     switch( nWhichId )
     298             :     {
     299             :         case SCHATTR_DATADESCR_SHOW_NUMBER:
     300             :         case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
     301             :         case SCHATTR_DATADESCR_SHOW_CATEGORY:
     302             :         case SCHATTR_DATADESCR_SHOW_SYMBOL:
     303             :         {
     304           0 :             const SfxBoolItem & rItem = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId ));
     305             : 
     306           0 :             uno::Any aOldValue = GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL);
     307           0 :             chart2::DataPointLabel aLabel;
     308           0 :             if( aOldValue >>= aLabel )
     309             :             {
     310             :                 sal_Bool& rValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : (
     311             :                     (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : (
     312           0 :                     (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
     313           0 :                 bool bOldValue = rValue;
     314           0 :                 rValue = rItem.GetValue();
     315           0 :                 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
     316             :                 {
     317           0 :                     Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
     318           0 :                     if( (bOldValue ? 1 : 0) != rValue ||
     319           0 :                         DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, CHART_UNONAME_LABEL , aOldValue ) )
     320             :                     {
     321           0 :                         DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_LABEL , uno::makeAny( aLabel ) );
     322           0 :                         bChanged = true;
     323           0 :                     }
     324             :                 }
     325           0 :                 else if( (bOldValue ? 1 : 0) != rValue )
     326             :                 {
     327           0 :                     GetPropertySet()->setPropertyValue(CHART_UNONAME_LABEL , uno::makeAny(aLabel));
     328           0 :                     bChanged = true;
     329             :                 }
     330           0 :             }
     331             :         }
     332           0 :         break;
     333             : 
     334             :         case SID_ATTR_NUMBERFORMAT_VALUE:
     335             :         case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:  //fall through intended
     336             :         {
     337           0 :             bChanged = lcl_NumberFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
     338             :         }
     339           0 :         break;
     340             : 
     341             :         case SID_ATTR_NUMBERFORMAT_SOURCE:
     342             :         case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended
     343             :         {
     344           0 :             bChanged = lcl_UseSourceFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
     345             :         }
     346           0 :         break;
     347             : 
     348             :         case SCHATTR_DATADESCR_SEPARATOR:
     349             :         {
     350           0 :             OUString aNewValue = static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue();
     351           0 :             OUString aOldValue;
     352             :             try
     353             :             {
     354           0 :                 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aOldValue;
     355           0 :                 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
     356             :                 {
     357           0 :                     Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
     358           0 :                     if( !aOldValue.equals(aNewValue) ||
     359           0 :                         DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelSeparator" , uno::makeAny( aOldValue ) ) )
     360             :                     {
     361           0 :                         DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelSeparator" , uno::makeAny( aNewValue ) );
     362           0 :                         bChanged = true;
     363           0 :                     }
     364             :                 }
     365           0 :                 else if( !aOldValue.equals(aNewValue) )
     366             :                 {
     367           0 :                     GetPropertySet()->setPropertyValue( "LabelSeparator" , uno::makeAny( aNewValue ));
     368           0 :                     bChanged = true;
     369             :                 }
     370             :             }
     371           0 :             catch( const uno::Exception& e )
     372             :             {
     373             :                 ASSERT_EXCEPTION( e );
     374           0 :             }
     375             :         }
     376           0 :         break;
     377             : 
     378             :         case SCHATTR_DATADESCR_PLACEMENT:
     379             :         {
     380             : 
     381             :             try
     382             :             {
     383           0 :                 sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
     384           0 :                 sal_Int32 nOld =0;
     385           0 :                 if( !(GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nOld) )
     386             :                 {
     387           0 :                     if( m_aAvailableLabelPlacements.getLength() )
     388           0 :                         nOld = m_aAvailableLabelPlacements[0];
     389             :                 }
     390           0 :                 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
     391             :                 {
     392           0 :                     Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
     393           0 :                     if( nOld!=nNew ||
     394           0 :                         DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelPlacement" , uno::makeAny( nOld ) ) )
     395             :                     {
     396           0 :                         DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelPlacement" , uno::makeAny( nNew ) );
     397           0 :                         bChanged = true;
     398           0 :                     }
     399             :                 }
     400           0 :                 else if( nOld!=nNew )
     401             :                 {
     402           0 :                     GetPropertySet()->setPropertyValue( "LabelPlacement" , uno::makeAny( nNew ));
     403           0 :                     bChanged = true;
     404             :                 }
     405             :             }
     406           0 :             catch( const uno::Exception& e )
     407             :             {
     408             :                 ASSERT_EXCEPTION( e );
     409             :             }
     410             :         }
     411           0 :         break;
     412             : 
     413             :         case SCHATTR_STYLE_SYMBOL:
     414             :         {
     415             :             sal_Int32 nStyle =
     416             :                 static_cast< const SfxInt32Item & >(
     417           0 :                     rItemSet.Get( nWhichId )).GetValue();
     418           0 :             chart2::Symbol aSymbol;
     419             : 
     420           0 :             GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
     421           0 :             sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol );
     422             : 
     423           0 :             if( nStyle != nOldStyle )
     424             :             {
     425           0 :                 bool bDeleteSymbol = false;
     426           0 :                 switch( nStyle )
     427             :                 {
     428             :                     case SVX_SYMBOLTYPE_NONE:
     429           0 :                         aSymbol.Style = chart2::SymbolStyle_NONE;
     430           0 :                         break;
     431             :                     case SVX_SYMBOLTYPE_AUTO:
     432           0 :                         aSymbol.Style = chart2::SymbolStyle_AUTO;
     433           0 :                         break;
     434             :                     case SVX_SYMBOLTYPE_BRUSHITEM:
     435           0 :                         aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
     436           0 :                         break;
     437             :                     case SVX_SYMBOLTYPE_UNKNOWN:
     438           0 :                         bDeleteSymbol = true;
     439           0 :                         break;
     440             : 
     441             :                     default:
     442           0 :                         aSymbol.Style = chart2::SymbolStyle_STANDARD;
     443           0 :                         aSymbol.StandardSymbol = nStyle;
     444             :                 }
     445             : 
     446           0 :                 if( bDeleteSymbol )
     447           0 :                     GetPropertySet()->setPropertyValue( "Symbol" , uno::Any());
     448             :                 else
     449           0 :                     GetPropertySet()->setPropertyValue( "Symbol" , uno::makeAny( aSymbol ));
     450           0 :                 bChanged = true;
     451           0 :             }
     452             :         }
     453           0 :         break;
     454             : 
     455             :         case SCHATTR_SYMBOL_SIZE:
     456             :         {
     457             :             Size aSize = static_cast< const SvxSizeItem & >(
     458           0 :                 rItemSet.Get( nWhichId )).GetSize();
     459           0 :             chart2::Symbol aSymbol;
     460             : 
     461           0 :             GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
     462           0 :             if( aSize.getWidth() != aSymbol.Size.Width ||
     463           0 :                 aSize.getHeight() != aSymbol.Size.Height )
     464             :             {
     465           0 :                 aSymbol.Size.Width = aSize.getWidth();
     466           0 :                 aSymbol.Size.Height = aSize.getHeight();
     467             : 
     468           0 :                 GetPropertySet()->setPropertyValue( "Symbol" , uno::makeAny( aSymbol ));
     469           0 :                 bChanged = true;
     470           0 :             }
     471             :         }
     472           0 :         break;
     473             : 
     474             :         case SCHATTR_SYMBOL_BRUSH:
     475             :         {
     476             :             const SvxBrushItem & rBrshItem( static_cast< const SvxBrushItem & >(
     477           0 :                                                 rItemSet.Get( nWhichId )));
     478           0 :             uno::Any aXGraphicAny;
     479           0 :             const Graphic *pGraphic( rBrshItem.GetGraphic());
     480           0 :             if( pGraphic )
     481             :             {
     482           0 :                 uno::Reference< graphic::XGraphic > xGraphic( pGraphic->GetXGraphic());
     483           0 :                 if( xGraphic.is())
     484             :                 {
     485           0 :                     aXGraphicAny <<= xGraphic;
     486           0 :                     chart2::Symbol aSymbol;
     487           0 :                     GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
     488           0 :                     if( aSymbol.Graphic != xGraphic )
     489             :                     {
     490           0 :                         aSymbol.Graphic = xGraphic;
     491           0 :                         GetPropertySet()->setPropertyValue( "Symbol" , uno::makeAny( aSymbol ));
     492           0 :                         bChanged = true;
     493           0 :                     }
     494           0 :                 }
     495           0 :             }
     496             :         }
     497           0 :         break;
     498             : 
     499             :         case SCHATTR_TEXT_DEGREES:
     500             :         {
     501             :             double fValue = static_cast< double >(
     502             :                 static_cast< const SfxInt32Item & >(
     503           0 :                     rItemSet.Get( nWhichId )).GetValue()) / 100.0;
     504           0 :             double fOldValue = 0.0;
     505             :             bool bPropExisted =
     506           0 :                 ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldValue );
     507             : 
     508           0 :             if( ! bPropExisted ||
     509           0 :                 ( bPropExisted && fOldValue != fValue ))
     510             :             {
     511           0 :                 GetPropertySet()->setPropertyValue( "TextRotation" , uno::makeAny( fValue ));
     512           0 :                 bChanged = true;
     513             :             }
     514             :         }
     515           0 :         break;
     516             :     }
     517             : 
     518           0 :     return bChanged;
     519             : }
     520             : 
     521           0 : void DataPointItemConverter::FillSpecialItem(
     522             :     sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
     523             :     throw( uno::Exception )
     524             : {
     525           0 :     switch( nWhichId )
     526             :     {
     527             :         case SCHATTR_DATADESCR_SHOW_NUMBER:
     528             :         case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
     529             :         case SCHATTR_DATADESCR_SHOW_CATEGORY:
     530             :         case SCHATTR_DATADESCR_SHOW_SYMBOL:
     531             :         {
     532           0 :             chart2::DataPointLabel aLabel;
     533           0 :             if (GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel)
     534             :             {
     535             :                 bool bValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : (
     536             :                     (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : (
     537           0 :                     (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
     538             : 
     539           0 :                 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
     540             : 
     541           0 :                 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
     542             :                 {
     543           0 :                     if( DataSeriesHelper::hasAttributedDataPointDifferentValue(
     544           0 :                         Reference< chart2::XDataSeries >( GetPropertySet(), uno::UNO_QUERY), CHART_UNONAME_LABEL , uno::makeAny(aLabel) ) )
     545             :                     {
     546           0 :                         rOutItemSet.InvalidateItem(nWhichId);
     547             :                     }
     548             :                 }
     549             :             }
     550             :         }
     551           0 :         break;
     552             : 
     553             :         case SID_ATTR_NUMBERFORMAT_VALUE:
     554             :         {
     555           0 :             sal_Int32 nKey = 0;
     556           0 :             if (!(GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nKey))
     557           0 :                 nKey = m_nNumberFormat;
     558           0 :             rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
     559             :         }
     560           0 :         break;
     561             : 
     562             :         case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:
     563             :         {
     564           0 :             sal_Int32 nKey = 0;
     565           0 :             if( !(GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ) >>= nKey) )
     566           0 :                 nKey = m_nPercentNumberFormat;
     567           0 :             rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
     568             :         }
     569           0 :         break;
     570             : 
     571             :         case SID_ATTR_NUMBERFORMAT_SOURCE:
     572             :         {
     573           0 :             bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue();
     574           0 :             rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
     575             :         }
     576           0 :         break;
     577             :         case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
     578             :         {
     579           0 :             bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ).hasValue());
     580           0 :             rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
     581             :         }
     582           0 :         break;
     583             : 
     584             :         case SCHATTR_DATADESCR_SEPARATOR:
     585             :         {
     586           0 :             OUString aValue;
     587             :             try
     588             :             {
     589           0 :                 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aValue;
     590           0 :                 rOutItemSet.Put( SfxStringItem( nWhichId, aValue ));
     591             :             }
     592           0 :             catch( const uno::Exception& e )
     593             :             {
     594             :                 ASSERT_EXCEPTION( e );
     595           0 :             }
     596             :         }
     597           0 :         break;
     598             : 
     599             :         case SCHATTR_DATADESCR_PLACEMENT:
     600             :         {
     601             :             try
     602             :             {
     603           0 :                 sal_Int32 nPlacement=0;
     604           0 :                 if( GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nPlacement )
     605           0 :                     rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement ));
     606           0 :                 else if( m_aAvailableLabelPlacements.getLength() )
     607           0 :                     rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] ));
     608             :             }
     609           0 :             catch( const uno::Exception& e )
     610             :             {
     611             :                 ASSERT_EXCEPTION( e );
     612             :             }
     613             :         }
     614           0 :         break;
     615             : 
     616             :         case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS:
     617             :         {
     618           0 :             rOutItemSet.Put( SfxIntegerListItem( nWhichId, m_aAvailableLabelPlacements ) );
     619             :         }
     620           0 :         break;
     621             : 
     622             :         case SCHATTR_DATADESCR_NO_PERCENTVALUE:
     623             :         {
     624           0 :             rOutItemSet.Put( SfxBoolItem( nWhichId, m_bForbidPercentValue ));
     625             :         }
     626           0 :         break;
     627             : 
     628             :         case SCHATTR_STYLE_SYMBOL:
     629             :         {
     630           0 :             chart2::Symbol aSymbol;
     631           0 :             if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
     632           0 :                 rOutItemSet.Put( SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) ));
     633             :         }
     634           0 :         break;
     635             : 
     636             :         case SCHATTR_SYMBOL_SIZE:
     637             :         {
     638           0 :             chart2::Symbol aSymbol;
     639           0 :             if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
     640             :                 rOutItemSet.Put(
     641           0 :                     SvxSizeItem( nWhichId, Size( aSymbol.Size.Width, aSymbol.Size.Height ) ));
     642             :         }
     643           0 :         break;
     644             : 
     645             :         case SCHATTR_SYMBOL_BRUSH:
     646             :         {
     647           0 :             chart2::Symbol aSymbol;
     648           0 :             if(( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
     649           0 :                && aSymbol.Graphic.is() )
     650             :             {
     651           0 :                 rOutItemSet.Put( SvxBrushItem( Graphic( aSymbol.Graphic ), GPOS_MM, SCHATTR_SYMBOL_BRUSH ));
     652           0 :             }
     653             :         }
     654           0 :         break;
     655             : 
     656             :         case SCHATTR_TEXT_DEGREES:
     657             :         {
     658           0 :             double fValue = 0;
     659             : 
     660           0 :             if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fValue )
     661             :             {
     662             :                 rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >(
     663           0 :                                                    ::rtl::math::round( fValue * 100.0 ) ) ));
     664             :             }
     665             :         }
     666           0 :         break;
     667             :    }
     668           0 : }
     669             : 
     670         102 : }}
     671             : 
     672             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10