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

Generated by: LCOV version 1.10