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

Generated by: LCOV version 1.10