LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/controller/itemsetwrapper - DataPointItemConverter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 295 0.3 %
Date: 2012-12-27 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 <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/brshitem.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             :         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( String(), 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             : 
     301           0 : bool DataPointItemConverter::ApplySpecialItem(
     302             :     sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
     303             :     throw( uno::Exception )
     304             : {
     305           0 :     bool bChanged = false;
     306           0 :     uno::Any aValue;
     307             : 
     308           0 :     switch( nWhichId )
     309             :     {
     310             :         case SCHATTR_DATADESCR_SHOW_NUMBER:
     311             :         case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
     312             :         case SCHATTR_DATADESCR_SHOW_CATEGORY:
     313             :         case SCHATTR_DATADESCR_SHOW_SYMBOL:
     314             :         {
     315           0 :             const SfxBoolItem & rItem = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId ));
     316             : 
     317           0 :             uno::Any aOldValue( GetPropertySet()->getPropertyValue( "Label" ));
     318           0 :             chart2::DataPointLabel aLabel;
     319           0 :             if( aOldValue >>= aLabel )
     320             :             {
     321             :                 sal_Bool& rValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : (
     322             :                     (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : (
     323           0 :                     (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
     324           0 :                 sal_Bool bOldValue = rValue;
     325           0 :                 rValue = static_cast< sal_Bool >( rItem.GetValue() );
     326           0 :                 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
     327             :                 {
     328           0 :                     Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
     329           0 :                     if( bOldValue != rValue ||
     330           0 :                         DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "Label" , aOldValue ) )
     331             :                     {
     332           0 :                         DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "Label" , uno::makeAny( aLabel ) );
     333           0 :                         bChanged = true;
     334           0 :                     }
     335             :                 }
     336           0 :                 else if( bOldValue != rValue )
     337             :                 {
     338           0 :                     GetPropertySet()->setPropertyValue( "Label" , uno::makeAny( aLabel ));
     339           0 :                     bChanged = true;
     340             :                 }
     341           0 :             }
     342             :         }
     343           0 :         break;
     344             : 
     345             :         case SID_ATTR_NUMBERFORMAT_VALUE:
     346             :         case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:  //fall through intended
     347             :         {
     348           0 :             bChanged = lcl_NumberFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
     349             :         }
     350           0 :         break;
     351             : 
     352             :         case SID_ATTR_NUMBERFORMAT_SOURCE:
     353             :         case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended
     354             :         {
     355           0 :             bChanged = lcl_UseSourceFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
     356             :         }
     357           0 :         break;
     358             : 
     359             :         case SCHATTR_DATADESCR_SEPARATOR:
     360             :         {
     361           0 :             OUString aNewValue = static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue();
     362           0 :             OUString aOldValue;
     363             :             try
     364             :             {
     365           0 :                 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aOldValue;
     366           0 :                 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
     367             :                 {
     368           0 :                     Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
     369           0 :                     if( !aOldValue.equals(aNewValue) ||
     370           0 :                         DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelSeparator" , uno::makeAny( aOldValue ) ) )
     371             :                     {
     372           0 :                         DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelSeparator" , uno::makeAny( aNewValue ) );
     373           0 :                         bChanged = true;
     374           0 :                     }
     375             :                 }
     376           0 :                 else if( !aOldValue.equals(aNewValue) )
     377             :                 {
     378           0 :                     GetPropertySet()->setPropertyValue( "LabelSeparator" , uno::makeAny( aNewValue ));
     379           0 :                     bChanged = true;
     380             :                 }
     381             :             }
     382           0 :             catch( const uno::Exception& e )
     383             :             {
     384             :                 ASSERT_EXCEPTION( e );
     385           0 :             }
     386             :         }
     387           0 :         break;
     388             : 
     389             :         case SCHATTR_DATADESCR_PLACEMENT:
     390             :         {
     391             : 
     392             :             try
     393             :             {
     394           0 :                 sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
     395           0 :                 sal_Int32 nOld =0;
     396           0 :                 if( !(GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nOld) )
     397             :                 {
     398           0 :                     if( m_aAvailableLabelPlacements.getLength() )
     399           0 :                         nOld = m_aAvailableLabelPlacements[0];
     400             :                 }
     401           0 :                 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
     402             :                 {
     403           0 :                     Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
     404           0 :                     if( nOld!=nNew ||
     405           0 :                         DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelPlacement" , uno::makeAny( nOld ) ) )
     406             :                     {
     407           0 :                         DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelPlacement" , uno::makeAny( nNew ) );
     408           0 :                         bChanged = true;
     409           0 :                     }
     410             :                 }
     411           0 :                 else if( nOld!=nNew )
     412             :                 {
     413           0 :                     GetPropertySet()->setPropertyValue( "LabelPlacement" , uno::makeAny( nNew ));
     414           0 :                     bChanged = true;
     415             :                 }
     416             :             }
     417           0 :             catch( const uno::Exception& e )
     418             :             {
     419             :                 ASSERT_EXCEPTION( e );
     420             :             }
     421             :         }
     422           0 :         break;
     423             : 
     424             :         case SCHATTR_STYLE_SYMBOL:
     425             :         {
     426             :             sal_Int32 nStyle =
     427             :                 static_cast< const SfxInt32Item & >(
     428           0 :                     rItemSet.Get( nWhichId )).GetValue();
     429           0 :             chart2::Symbol aSymbol;
     430             : 
     431           0 :             GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
     432           0 :             sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol );
     433             : 
     434           0 :             if( nStyle != nOldStyle )
     435             :             {
     436           0 :                 bool bDeleteSymbol = false;
     437           0 :                 switch( nStyle )
     438             :                 {
     439             :                     case SVX_SYMBOLTYPE_NONE:
     440           0 :                         aSymbol.Style = chart2::SymbolStyle_NONE;
     441           0 :                         break;
     442             :                     case SVX_SYMBOLTYPE_AUTO:
     443           0 :                         aSymbol.Style = chart2::SymbolStyle_AUTO;
     444           0 :                         break;
     445             :                     case SVX_SYMBOLTYPE_BRUSHITEM:
     446           0 :                         aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
     447           0 :                         break;
     448             :                     case SVX_SYMBOLTYPE_UNKNOWN:
     449           0 :                         bDeleteSymbol = true;
     450           0 :                         break;
     451             : 
     452             :                     default:
     453           0 :                         aSymbol.Style = chart2::SymbolStyle_STANDARD;
     454           0 :                         aSymbol.StandardSymbol = nStyle;
     455             :                 }
     456             : 
     457           0 :                 if( bDeleteSymbol )
     458           0 :                     GetPropertySet()->setPropertyValue( "Symbol" , uno::Any());
     459             :                 else
     460           0 :                     GetPropertySet()->setPropertyValue( "Symbol" , uno::makeAny( aSymbol ));
     461           0 :                 bChanged = true;
     462           0 :             }
     463             :         }
     464           0 :         break;
     465             : 
     466             :         case SCHATTR_SYMBOL_SIZE:
     467             :         {
     468             :             Size aSize = static_cast< const SvxSizeItem & >(
     469           0 :                 rItemSet.Get( nWhichId )).GetSize();
     470           0 :             chart2::Symbol aSymbol;
     471             : 
     472           0 :             GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
     473           0 :             if( aSize.getWidth() != aSymbol.Size.Width ||
     474           0 :                 aSize.getHeight() != aSymbol.Size.Height )
     475             :             {
     476           0 :                 aSymbol.Size.Width = aSize.getWidth();
     477           0 :                 aSymbol.Size.Height = aSize.getHeight();
     478             : 
     479           0 :                 GetPropertySet()->setPropertyValue( "Symbol" , uno::makeAny( aSymbol ));
     480           0 :                 bChanged = true;
     481           0 :             }
     482             :         }
     483           0 :         break;
     484             : 
     485             :         case SCHATTR_SYMBOL_BRUSH:
     486             :         {
     487             :             const SvxBrushItem & rBrshItem( static_cast< const SvxBrushItem & >(
     488           0 :                                                 rItemSet.Get( nWhichId )));
     489           0 :             uno::Any aXGraphicAny;
     490           0 :             const Graphic *pGraphic( rBrshItem.GetGraphic());
     491           0 :             if( pGraphic )
     492             :             {
     493           0 :                 uno::Reference< graphic::XGraphic > xGraphic( pGraphic->GetXGraphic());
     494           0 :                 if( xGraphic.is())
     495             :                 {
     496           0 :                     aXGraphicAny <<= xGraphic;
     497           0 :                     chart2::Symbol aSymbol;
     498           0 :                     GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
     499           0 :                     if( aSymbol.Graphic != xGraphic )
     500             :                     {
     501           0 :                         aSymbol.Graphic = xGraphic;
     502           0 :                         GetPropertySet()->setPropertyValue( "Symbol" , uno::makeAny( aSymbol ));
     503           0 :                         bChanged = true;
     504           0 :                     }
     505           0 :                 }
     506           0 :             }
     507             :         }
     508           0 :         break;
     509             : 
     510             :         case SCHATTR_TEXT_DEGREES:
     511             :         {
     512             :             double fValue = static_cast< double >(
     513             :                 static_cast< const SfxInt32Item & >(
     514           0 :                     rItemSet.Get( nWhichId )).GetValue()) / 100.0;
     515           0 :             double fOldValue = 0.0;
     516             :             bool bPropExisted =
     517           0 :                 ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldValue );
     518             : 
     519           0 :             if( ! bPropExisted ||
     520             :                 ( bPropExisted && fOldValue != fValue ))
     521             :             {
     522           0 :                 GetPropertySet()->setPropertyValue( "TextRotation" , uno::makeAny( fValue ));
     523           0 :                 bChanged = true;
     524             :             }
     525             :         }
     526           0 :         break;
     527             :     }
     528             : 
     529           0 :     return bChanged;
     530             : }
     531             : 
     532           0 : void DataPointItemConverter::FillSpecialItem(
     533             :     sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
     534             :     throw( uno::Exception )
     535             : {
     536           0 :     switch( nWhichId )
     537             :     {
     538             :         case SCHATTR_DATADESCR_SHOW_NUMBER:
     539             :         case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
     540             :         case SCHATTR_DATADESCR_SHOW_CATEGORY:
     541             :         case SCHATTR_DATADESCR_SHOW_SYMBOL:
     542             :         {
     543           0 :             chart2::DataPointLabel aLabel;
     544           0 :             if( GetPropertySet()->getPropertyValue( "Label" ) >>= aLabel )
     545             :             {
     546             :                 sal_Bool bValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : (
     547             :                     (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : (
     548           0 :                     (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
     549             : 
     550           0 :                 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
     551             : 
     552           0 :                 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
     553             :                 {
     554           0 :                     if( DataSeriesHelper::hasAttributedDataPointDifferentValue(
     555           0 :                         Reference< chart2::XDataSeries >( GetPropertySet(), uno::UNO_QUERY), "Label" , uno::makeAny(aLabel) ) )
     556             :                     {
     557           0 :                         rOutItemSet.InvalidateItem(nWhichId);
     558             :                     }
     559             :                 }
     560             :             }
     561             :         }
     562           0 :         break;
     563             : 
     564             :         case SID_ATTR_NUMBERFORMAT_VALUE:
     565             :         {
     566           0 :             sal_Int32 nKey = 0;
     567           0 :             if( !(GetPropertySet()->getPropertyValue( "NumberFormat" ) >>= nKey) )
     568           0 :                 nKey = m_nNumberFormat;
     569           0 :             rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
     570             :         }
     571           0 :         break;
     572             : 
     573             :         case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:
     574             :         {
     575           0 :             sal_Int32 nKey = 0;
     576           0 :             if( !(GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ) >>= nKey) )
     577           0 :                 nKey = m_nPercentNumberFormat;
     578           0 :             rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
     579             :         }
     580           0 :         break;
     581             : 
     582             :         case SID_ATTR_NUMBERFORMAT_SOURCE:
     583             :         {
     584           0 :             bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( "NumberFormat" ).hasValue());
     585           0 :             rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
     586             :         }
     587           0 :         break;
     588             :         case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
     589             :         {
     590           0 :             bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ).hasValue());
     591           0 :             rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
     592             :         }
     593           0 :         break;
     594             : 
     595             :         case SCHATTR_DATADESCR_SEPARATOR:
     596             :         {
     597           0 :             OUString aValue;
     598             :             try
     599             :             {
     600           0 :                 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aValue;
     601           0 :                 rOutItemSet.Put( SfxStringItem( nWhichId, aValue ));
     602             :             }
     603           0 :             catch( const uno::Exception& e )
     604             :             {
     605             :                 ASSERT_EXCEPTION( e );
     606           0 :             }
     607             :         }
     608           0 :         break;
     609             : 
     610             :         case SCHATTR_DATADESCR_PLACEMENT:
     611             :         {
     612             :             try
     613             :             {
     614           0 :                 sal_Int32 nPlacement=0;
     615           0 :                 if( GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nPlacement )
     616           0 :                     rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement ));
     617           0 :                 else if( m_aAvailableLabelPlacements.getLength() )
     618           0 :                     rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] ));
     619             :             }
     620           0 :             catch( const uno::Exception& e )
     621             :             {
     622             :                 ASSERT_EXCEPTION( e );
     623             :             }
     624             :         }
     625           0 :         break;
     626             : 
     627             :         case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS:
     628             :         {
     629           0 :             rOutItemSet.Put( SfxIntegerListItem( nWhichId, m_aAvailableLabelPlacements ) );
     630             :         }
     631           0 :         break;
     632             : 
     633             :         case SCHATTR_DATADESCR_NO_PERCENTVALUE:
     634             :         {
     635           0 :             rOutItemSet.Put( SfxBoolItem( nWhichId, m_bForbidPercentValue ));
     636             :         }
     637           0 :         break;
     638             : 
     639             :         case SCHATTR_STYLE_SYMBOL:
     640             :         {
     641           0 :             chart2::Symbol aSymbol;
     642           0 :             if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
     643           0 :                 rOutItemSet.Put( SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) ));
     644             :         }
     645           0 :         break;
     646             : 
     647             :         case SCHATTR_SYMBOL_SIZE:
     648             :         {
     649           0 :             chart2::Symbol aSymbol;
     650           0 :             if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
     651             :                 rOutItemSet.Put(
     652           0 :                     SvxSizeItem( nWhichId, Size( aSymbol.Size.Width, aSymbol.Size.Height ) ));
     653             :         }
     654           0 :         break;
     655             : 
     656             :         case SCHATTR_SYMBOL_BRUSH:
     657             :         {
     658           0 :             chart2::Symbol aSymbol;
     659           0 :             if(( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
     660           0 :                && aSymbol.Graphic.is() )
     661             :             {
     662           0 :                 rOutItemSet.Put( SvxBrushItem( Graphic( aSymbol.Graphic ), GPOS_MM, SCHATTR_SYMBOL_BRUSH ));
     663           0 :             }
     664             :         }
     665           0 :         break;
     666             : 
     667             :         case SCHATTR_TEXT_DEGREES:
     668             :         {
     669           0 :             double fValue = 0;
     670             : 
     671           0 :             if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fValue )
     672             :             {
     673             :                 rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >(
     674           0 :                                                    ::rtl::math::round( fValue * 100.0 ) ) ));
     675             :             }
     676             :         }
     677           0 :         break;
     678             :    }
     679           0 : }
     680             : 
     681             : } //  namespace wrapper
     682           3 : } //  namespace chart
     683             : 
     684             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10