Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / controller / itemsetwrapper / DataPointItemConverter.cxx
blob9aa54f554bb9343aacf2b4206f90960e9169cc44
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <DataPointItemConverter.hxx>
21 #include "SchWhichPairs.hxx"
22 #include <ItemPropertyMap.hxx>
24 #include <GraphicPropertyItemConverter.hxx>
25 #include <CharacterPropertyItemConverter.hxx>
26 #include <StatisticsItemConverter.hxx>
27 #include <SeriesOptionsItemConverter.hxx>
28 #include <DataSeriesHelper.hxx>
29 #include <DiagramHelper.hxx>
30 #include <ChartModelHelper.hxx>
31 #include <ChartTypeHelper.hxx>
32 #include <unonames.hxx>
34 #include <svx/chrtitem.hxx>
35 #include <com/sun/star/chart2/DataPointLabel.hpp>
36 #include <com/sun/star/chart2/Symbol.hpp>
38 #include <svx/xflclit.hxx>
39 #include <svl/intitem.hxx>
40 #include <editeng/sizeitem.hxx>
41 #include <svl/stritem.hxx>
42 #include <editeng/brushitem.hxx>
43 #include <svl/ilstitem.hxx>
44 #include <vcl/graph.hxx>
45 #include <com/sun/star/graphic/XGraphic.hpp>
47 #include <svx/tabline.hxx>
49 #include <functional>
50 #include <algorithm>
51 #include <memory>
53 using namespace ::com::sun::star;
54 using namespace ::com::sun::star::chart2;
55 using ::com::sun::star::uno::Reference;
57 namespace chart { namespace wrapper {
59 namespace {
61 ItemPropertyMapType & lcl_GetDataPointPropertyMap()
63 static ItemPropertyMapType aDataPointPropertyMap{
64 {SCHATTR_STYLE_SHAPE, {"Geometry3D", 0}}};
65 return aDataPointPropertyMap;
68 sal_Int32 lcl_getSymbolStyleForSymbol( const chart2::Symbol & rSymbol )
70 sal_Int32 nStyle = SVX_SYMBOLTYPE_UNKNOWN;
71 switch( rSymbol.Style )
73 case chart2::SymbolStyle_NONE:
74 nStyle = SVX_SYMBOLTYPE_NONE;
75 break;
76 case chart2::SymbolStyle_AUTO:
77 nStyle = SVX_SYMBOLTYPE_AUTO;
78 break;
79 case chart2::SymbolStyle_GRAPHIC:
80 nStyle = SVX_SYMBOLTYPE_BRUSHITEM;
81 break;
82 case chart2::SymbolStyle_STANDARD:
83 nStyle = rSymbol.StandardSymbol;
84 break;
86 case chart2::SymbolStyle_POLYGON:
87 // to avoid warning
88 case chart2::SymbolStyle::SymbolStyle_MAKE_FIXED_SIZE:
89 // nothing
90 break;
92 return nStyle;
95 bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso )
97 bool bChanged = false;
98 if( !xPropertySet.is() )
99 return bChanged;
100 OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_VALUE) ? OUString(CHART_UNONAME_NUMFMT) : OUString( "PercentageNumberFormat" );
101 sal_uInt16 nSourceWhich = (nWhichId==SID_ATTR_NUMBERFORMAT_VALUE) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE;
103 if( rItemSet.GetItemState( nSourceWhich ) != SfxItemState::SET )
104 return bChanged;
106 uno::Any aValue;
107 bool bUseSourceFormat = static_cast< const SfxBoolItem & >(
108 rItemSet.Get( nSourceWhich )).GetValue();
109 if( !bUseSourceFormat )
111 SfxItemState aState = rItemSet.GetItemState( nWhichId );
112 if( aState == SfxItemState::SET )
114 sal_Int32 nFmt = static_cast< sal_Int32 >(
115 static_cast< const SfxUInt32Item & >(
116 rItemSet.Get( nWhichId )).GetValue());
117 aValue <<= nFmt;
119 else
120 return bChanged;
123 uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
124 if( bOverwriteAttributedDataPointsAlso )
126 Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY);
127 if( aValue != aOldValue ||
128 ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
130 ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aValue );
131 bChanged = true;
134 else if( aOldValue != aValue )
136 xPropertySet->setPropertyValue(aPropertyName, aValue );
137 bChanged = true;
139 return bChanged;
142 bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso )
144 bool bChanged = false;
145 if( !xPropertySet.is() )
146 return bChanged;
147 OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_SOURCE) ? OUString(CHART_UNONAME_NUMFMT) : OUString( "PercentageNumberFormat" );
148 sal_uInt16 nFormatWhich = (nWhichId==SID_ATTR_NUMBERFORMAT_SOURCE) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE;
150 if( rItemSet.GetItemState( nWhichId ) != SfxItemState::SET )
151 return bChanged;
153 uno::Any aNewValue;
154 bool bUseSourceFormat = static_cast< const SfxBoolItem & >(
155 rItemSet.Get( nWhichId )).GetValue();
156 if( !bUseSourceFormat )
158 SfxItemState aState = rItemSet.GetItemState( nFormatWhich );
159 if( aState == SfxItemState::SET )
161 sal_Int32 nFormatKey = static_cast< sal_Int32 >(
162 static_cast< const SfxUInt32Item & >(
163 rItemSet.Get( nFormatWhich )).GetValue());
164 aNewValue <<= nFormatKey;
166 else
167 return bChanged;
170 uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
171 if( bOverwriteAttributedDataPointsAlso )
173 Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY);
174 if( aNewValue != aOldValue ||
175 ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
177 ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aNewValue );
178 bChanged = true;
181 else if( aOldValue != aNewValue )
183 xPropertySet->setPropertyValue( aPropertyName, aNewValue );
184 bChanged = true;
187 return bChanged;
190 } // anonymous namespace
192 DataPointItemConverter::DataPointItemConverter(
193 const uno::Reference< frame::XModel > & xChartModel,
194 const uno::Reference< uno::XComponentContext > & xContext,
195 const uno::Reference< beans::XPropertySet > & rPropertySet,
196 const uno::Reference< XDataSeries > & xSeries,
197 SfxItemPool& rItemPool,
198 SdrModel& rDrawModel,
199 const uno::Reference<lang::XMultiServiceFactory>& xNamedPropertyContainerFactory,
200 GraphicObjectType eMapTo,
201 const awt::Size* pRefSize,
202 bool bDataSeries,
203 bool bUseSpecialFillColor,
204 sal_Int32 nSpecialFillColor,
205 bool bOverwriteLabelsForAttributedDataPointsAlso,
206 sal_Int32 nNumberFormat,
207 sal_Int32 nPercentNumberFormat ) :
208 ItemConverter( rPropertySet, rItemPool ),
209 m_bDataSeries( bDataSeries ),
210 m_bOverwriteLabelsForAttributedDataPointsAlso(m_bDataSeries && bOverwriteLabelsForAttributedDataPointsAlso),
211 m_bUseSpecialFillColor(bUseSpecialFillColor),
212 m_nSpecialFillColor(nSpecialFillColor),
213 m_nNumberFormat(nNumberFormat),
214 m_nPercentNumberFormat(nPercentNumberFormat),
215 m_aAvailableLabelPlacements(),
216 m_bForbidPercentValue(true)
218 m_aConverters.push_back( new GraphicPropertyItemConverter(
219 rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, eMapTo ));
220 m_aConverters.push_back( new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize"));
221 if( bDataSeries )
223 m_aConverters.push_back( new StatisticsItemConverter( xChartModel, rPropertySet, rItemPool ));
224 m_aConverters.push_back( new SeriesOptionsItemConverter( xChartModel, xContext, rPropertySet, rItemPool ));
227 uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) );
228 uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xSeries ) );
229 bool bFound = false;
230 bool bAmbiguous = false;
231 bool bSwapXAndY = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
232 m_aAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements( xChartType, bSwapXAndY, xSeries );
234 m_bForbidPercentValue = ChartTypeHelper::getAxisType( xChartType, 0 ) != AxisType::CATEGORY;
237 DataPointItemConverter::~DataPointItemConverter()
239 std::for_each(m_aConverters.begin(), m_aConverters.end(), std::default_delete<ItemConverter>());
242 void DataPointItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
244 for( const auto& pConv : m_aConverters )
245 pConv->FillItemSet( rOutItemSet );
247 // own items
248 ItemConverter::FillItemSet( rOutItemSet );
250 if( m_bUseSpecialFillColor )
252 Color aColor(m_nSpecialFillColor);
253 rOutItemSet.Put( XFillColorItem( OUString(), aColor ) );
257 bool DataPointItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
259 bool bResult = false;
261 for( const auto& pConv : m_aConverters )
262 bResult = pConv->ApplyItemSet( rItemSet ) || bResult;
264 // own items
265 return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
268 const sal_uInt16 * DataPointItemConverter::GetWhichPairs() const
270 // must span all used items!
271 if( m_bDataSeries )
272 return nRowWhichPairs;
273 return nDataPointWhichPairs;
276 bool DataPointItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
278 ItemPropertyMapType & rMap( lcl_GetDataPointPropertyMap());
279 ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
281 if( aIt == rMap.end())
282 return false;
284 rOutProperty =(*aIt).second;
285 return true;
288 bool DataPointItemConverter::ApplySpecialItem(
289 sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
291 bool bChanged = false;
293 switch( nWhichId )
295 case SCHATTR_DATADESCR_SHOW_NUMBER:
296 case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
297 case SCHATTR_DATADESCR_SHOW_CATEGORY:
298 case SCHATTR_DATADESCR_SHOW_SYMBOL:
300 const SfxBoolItem & rItem = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId ));
302 uno::Any aOldValue = GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL);
303 chart2::DataPointLabel aLabel;
304 if( aOldValue >>= aLabel )
306 sal_Bool& rValue = (nWhichId==SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : (
307 (nWhichId==SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : (
308 (nWhichId==SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
309 bool bOldValue = rValue;
310 rValue = rItem.GetValue();
311 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
313 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
314 if( bOldValue != bool(rValue) ||
315 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, CHART_UNONAME_LABEL , aOldValue ) )
317 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_LABEL , uno::Any( aLabel ) );
318 bChanged = true;
321 else if( bOldValue != bool(rValue) )
323 GetPropertySet()->setPropertyValue(CHART_UNONAME_LABEL , uno::Any(aLabel));
324 bChanged = true;
328 break;
330 case SID_ATTR_NUMBERFORMAT_VALUE:
331 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: //fall through intended
333 bChanged = lcl_NumberFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
335 break;
337 case SID_ATTR_NUMBERFORMAT_SOURCE:
338 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended
340 bChanged = lcl_UseSourceFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
342 break;
344 case SCHATTR_DATADESCR_SEPARATOR:
346 OUString aNewValue = static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue();
347 OUString aOldValue;
350 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aOldValue;
351 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
353 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
354 if( aOldValue != aNewValue ||
355 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelSeparator" , uno::Any( aOldValue ) ) )
357 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelSeparator" , uno::Any( aNewValue ) );
358 bChanged = true;
361 else if( aOldValue != aNewValue )
363 GetPropertySet()->setPropertyValue( "LabelSeparator" , uno::Any( aNewValue ));
364 bChanged = true;
367 catch( const uno::Exception& e )
369 SAL_WARN("chart2", "Exception caught. " << e );
372 break;
374 case SCHATTR_DATADESCR_WRAP_TEXT:
379 bool bNew = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
380 bool bOld = false;
381 GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bOld;
382 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
384 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
385 if( bOld!=bNew ||
386 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "TextWordWrap", uno::Any( bOld ) ) )
388 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "TextWordWrap", uno::Any( bNew ) );
389 bChanged = true;
392 else if( bOld!=bNew )
394 GetPropertySet()->setPropertyValue( "TextWordWrap", uno::Any( bNew ));
395 bChanged = true;
398 catch( const uno::Exception& e )
400 SAL_WARN("chart2", "Exception caught. " << e );
403 break;
405 case SCHATTR_DATADESCR_PLACEMENT:
410 sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
411 sal_Int32 nOld =0;
412 if( !(GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nOld) )
414 if( m_aAvailableLabelPlacements.getLength() )
415 nOld = m_aAvailableLabelPlacements[0];
417 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
419 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
420 if( nOld!=nNew ||
421 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelPlacement" , uno::Any( nOld ) ) )
423 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelPlacement" , uno::Any( nNew ) );
424 bChanged = true;
427 else if( nOld!=nNew )
429 GetPropertySet()->setPropertyValue( "LabelPlacement" , uno::Any( nNew ));
430 bChanged = true;
433 catch( const uno::Exception& e )
435 SAL_WARN("chart2", "Exception caught. " << e );
438 break;
440 case SCHATTR_STYLE_SYMBOL:
442 sal_Int32 nStyle =
443 static_cast< const SfxInt32Item & >(
444 rItemSet.Get( nWhichId )).GetValue();
445 chart2::Symbol aSymbol;
447 GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
448 sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol );
450 if( nStyle != nOldStyle )
452 bool bDeleteSymbol = false;
453 switch( nStyle )
455 case SVX_SYMBOLTYPE_NONE:
456 aSymbol.Style = chart2::SymbolStyle_NONE;
457 break;
458 case SVX_SYMBOLTYPE_AUTO:
459 aSymbol.Style = chart2::SymbolStyle_AUTO;
460 break;
461 case SVX_SYMBOLTYPE_BRUSHITEM:
462 aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
463 break;
464 case SVX_SYMBOLTYPE_UNKNOWN:
465 bDeleteSymbol = true;
466 break;
468 default:
469 aSymbol.Style = chart2::SymbolStyle_STANDARD;
470 aSymbol.StandardSymbol = nStyle;
473 if( bDeleteSymbol )
474 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any());
475 else
476 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol ));
477 bChanged = true;
480 break;
482 case SCHATTR_SYMBOL_SIZE:
484 Size aSize = static_cast< const SvxSizeItem & >(
485 rItemSet.Get( nWhichId )).GetSize();
486 chart2::Symbol aSymbol;
488 GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
489 if( aSize.getWidth() != aSymbol.Size.Width ||
490 aSize.getHeight() != aSymbol.Size.Height )
492 aSymbol.Size.Width = aSize.getWidth();
493 aSymbol.Size.Height = aSize.getHeight();
495 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol ));
496 bChanged = true;
499 break;
501 case SCHATTR_SYMBOL_BRUSH:
503 const SvxBrushItem & rBrshItem( static_cast< const SvxBrushItem & >(
504 rItemSet.Get( nWhichId )));
505 uno::Any aXGraphicAny;
506 const Graphic *pGraphic( rBrshItem.GetGraphic());
507 if( pGraphic )
509 uno::Reference< graphic::XGraphic > xGraphic( pGraphic->GetXGraphic());
510 if( xGraphic.is())
512 aXGraphicAny <<= xGraphic;
513 chart2::Symbol aSymbol;
514 GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
515 if( aSymbol.Graphic != xGraphic )
517 aSymbol.Graphic = xGraphic;
518 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol ));
519 bChanged = true;
524 break;
526 case SCHATTR_TEXT_DEGREES:
528 double fValue = static_cast< double >(
529 static_cast< const SfxInt32Item & >(
530 rItemSet.Get( nWhichId )).GetValue()) / 100.0;
531 double fOldValue = 0.0;
532 bool bPropExisted =
533 ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldValue );
535 if( ! bPropExisted || fOldValue != fValue )
537 GetPropertySet()->setPropertyValue( "TextRotation" , uno::Any( fValue ));
538 bChanged = true;
541 break;
544 return bChanged;
547 void DataPointItemConverter::FillSpecialItem(
548 sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
550 switch( nWhichId )
552 case SCHATTR_DATADESCR_SHOW_NUMBER:
553 case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
554 case SCHATTR_DATADESCR_SHOW_CATEGORY:
555 case SCHATTR_DATADESCR_SHOW_SYMBOL:
557 chart2::DataPointLabel aLabel;
558 if (GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel)
560 bool bValue = (nWhichId==SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : (
561 (nWhichId==SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : (
562 (nWhichId==SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
564 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
566 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
568 if( DataSeriesHelper::hasAttributedDataPointDifferentValue(
569 Reference< chart2::XDataSeries >( GetPropertySet(), uno::UNO_QUERY), CHART_UNONAME_LABEL , uno::Any(aLabel) ) )
571 rOutItemSet.InvalidateItem(nWhichId);
576 break;
578 case SID_ATTR_NUMBERFORMAT_VALUE:
580 sal_Int32 nKey = 0;
581 if (!(GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nKey))
582 nKey = m_nNumberFormat;
583 rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
585 break;
587 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:
589 sal_Int32 nKey = 0;
590 if( !(GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ) >>= nKey) )
591 nKey = m_nPercentNumberFormat;
592 rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
594 break;
596 case SID_ATTR_NUMBERFORMAT_SOURCE:
598 bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue();
599 rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
601 break;
602 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
604 bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ).hasValue();
605 rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
607 break;
609 case SCHATTR_DATADESCR_SEPARATOR:
611 OUString aValue;
614 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aValue;
615 rOutItemSet.Put( SfxStringItem( nWhichId, aValue ));
617 catch( const uno::Exception& e )
619 SAL_WARN("chart2", "Exception caught. " << e );
622 break;
624 case SCHATTR_DATADESCR_WRAP_TEXT:
628 bool bValue = false;
629 GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bValue;
630 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
632 catch( const uno::Exception& e )
634 SAL_WARN("chart2", "Exception caught. " << e );
637 break;
639 case SCHATTR_DATADESCR_PLACEMENT:
643 sal_Int32 nPlacement=0;
644 if( GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nPlacement )
645 rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement ));
646 else if( m_aAvailableLabelPlacements.getLength() )
647 rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] ));
649 catch( const uno::Exception& e )
651 SAL_WARN("chart2", "Exception caught. " << e );
654 break;
656 case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS:
658 rOutItemSet.Put( SfxIntegerListItem( nWhichId, m_aAvailableLabelPlacements ) );
660 break;
662 case SCHATTR_DATADESCR_NO_PERCENTVALUE:
664 rOutItemSet.Put( SfxBoolItem( nWhichId, m_bForbidPercentValue ));
666 break;
668 case SCHATTR_STYLE_SYMBOL:
670 chart2::Symbol aSymbol;
671 if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
672 rOutItemSet.Put( SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) ));
674 break;
676 case SCHATTR_SYMBOL_SIZE:
678 chart2::Symbol aSymbol;
679 if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
680 rOutItemSet.Put(
681 SvxSizeItem( nWhichId, Size( aSymbol.Size.Width, aSymbol.Size.Height ) ));
683 break;
685 case SCHATTR_SYMBOL_BRUSH:
687 chart2::Symbol aSymbol;
688 if(( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
689 && aSymbol.Graphic.is() )
691 rOutItemSet.Put( SvxBrushItem( Graphic( aSymbol.Graphic ), GPOS_MM, SCHATTR_SYMBOL_BRUSH ));
694 break;
696 case SCHATTR_TEXT_DEGREES:
698 double fValue = 0;
700 if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fValue )
702 rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >(
703 ::rtl::math::round( fValue * 100.0 ) ) ));
706 break;
712 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */