vcl: allow for overriding the default PDF rendering resolution
[LibreOffice.git] / chart2 / source / controller / itemsetwrapper / DataPointItemConverter.cxx
blobcdc70149a91f3e5d6dfb4684249659883b81a832
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 <com/sun/star/chart2/AxisType.hpp>
35 #include <com/sun/star/chart2/DataPointLabel.hpp>
36 #include <com/sun/star/chart2/Symbol.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <sal/log.hxx>
40 #include <svx/xflclit.hxx>
41 #include <svl/eitem.hxx>
42 #include <svl/intitem.hxx>
43 #include <editeng/sizeitem.hxx>
44 #include <svl/stritem.hxx>
45 #include <editeng/brushitem.hxx>
46 #include <svl/ilstitem.hxx>
47 #include <tools/diagnose_ex.h>
48 #include <vcl/graph.hxx>
50 #include <svx/tabline.hxx>
52 #include <memory>
54 using namespace ::com::sun::star;
55 using namespace ::com::sun::star::chart2;
56 using ::com::sun::star::uno::Reference;
58 namespace chart { namespace wrapper {
60 namespace {
62 ItemPropertyMapType & lcl_GetDataPointPropertyMap()
64 static ItemPropertyMapType aDataPointPropertyMap{
65 {SCHATTR_STYLE_SHAPE, {"Geometry3D", 0}}};
66 return aDataPointPropertyMap;
69 sal_Int32 lcl_getSymbolStyleForSymbol( const chart2::Symbol & rSymbol )
71 sal_Int32 nStyle = SVX_SYMBOLTYPE_UNKNOWN;
72 switch( rSymbol.Style )
74 case chart2::SymbolStyle_NONE:
75 nStyle = SVX_SYMBOLTYPE_NONE;
76 break;
77 case chart2::SymbolStyle_AUTO:
78 nStyle = SVX_SYMBOLTYPE_AUTO;
79 break;
80 case chart2::SymbolStyle_GRAPHIC:
81 nStyle = SVX_SYMBOLTYPE_BRUSHITEM;
82 break;
83 case chart2::SymbolStyle_STANDARD:
84 nStyle = rSymbol.StandardSymbol;
85 break;
87 case chart2::SymbolStyle_POLYGON:
88 // to avoid warning
89 case chart2::SymbolStyle::SymbolStyle_MAKE_FIXED_SIZE:
90 // nothing
91 break;
93 return nStyle;
96 bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso )
98 bool bChanged = false;
99 if( !xPropertySet.is() )
100 return bChanged;
101 OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_VALUE) ? OUString(CHART_UNONAME_NUMFMT) : OUString( "PercentageNumberFormat" );
102 sal_uInt16 nSourceWhich = (nWhichId==SID_ATTR_NUMBERFORMAT_VALUE) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE;
104 if( rItemSet.GetItemState( nSourceWhich ) != SfxItemState::SET )
105 return bChanged;
107 uno::Any aValue;
108 bool bUseSourceFormat = static_cast< const SfxBoolItem & >(
109 rItemSet.Get( nSourceWhich )).GetValue();
110 if( !bUseSourceFormat )
112 SfxItemState aState = rItemSet.GetItemState( nWhichId );
113 if( aState == SfxItemState::SET )
115 sal_Int32 nFmt = static_cast< sal_Int32 >(
116 static_cast< const SfxUInt32Item & >(
117 rItemSet.Get( nWhichId )).GetValue());
118 aValue <<= nFmt;
120 else
121 return bChanged;
124 uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
125 if( bOverwriteAttributedDataPointsAlso )
127 Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY);
128 if( aValue != aOldValue ||
129 ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
131 ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aValue );
132 bChanged = true;
135 else if( aOldValue != aValue )
137 xPropertySet->setPropertyValue(aPropertyName, aValue );
138 bChanged = true;
140 return bChanged;
143 bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso )
145 bool bChanged = false;
146 if( !xPropertySet.is() )
147 return bChanged;
148 OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_SOURCE) ? OUString(CHART_UNONAME_NUMFMT) : OUString( "PercentageNumberFormat" );
149 sal_uInt16 nFormatWhich = (nWhichId==SID_ATTR_NUMBERFORMAT_SOURCE) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE;
151 if( rItemSet.GetItemState( nWhichId ) != SfxItemState::SET )
152 return bChanged;
154 uno::Any aNewValue;
155 bool bUseSourceFormat = static_cast< const SfxBoolItem & >(
156 rItemSet.Get( nWhichId )).GetValue();
157 xPropertySet->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(bUseSourceFormat));
158 if( !bUseSourceFormat )
160 SfxItemState aState = rItemSet.GetItemState( nFormatWhich );
161 if( aState == SfxItemState::SET )
163 sal_Int32 nFormatKey = static_cast< sal_Int32 >(
164 static_cast< const SfxUInt32Item & >(
165 rItemSet.Get( nFormatWhich )).GetValue());
166 aNewValue <<= nFormatKey;
168 else
169 return bChanged;
172 uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
173 if( bOverwriteAttributedDataPointsAlso )
175 Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY);
176 if( aNewValue != aOldValue ||
177 ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
179 ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aNewValue );
180 bChanged = true;
183 else if( aOldValue != aNewValue )
185 xPropertySet->setPropertyValue( aPropertyName, aNewValue );
186 bChanged = true;
189 return bChanged;
192 } // anonymous namespace
194 DataPointItemConverter::DataPointItemConverter(
195 const uno::Reference< frame::XModel > & xChartModel,
196 const uno::Reference< uno::XComponentContext > & xContext,
197 const uno::Reference< beans::XPropertySet > & rPropertySet,
198 const uno::Reference< XDataSeries > & xSeries,
199 SfxItemPool& rItemPool,
200 SdrModel& rDrawModel,
201 const uno::Reference<lang::XMultiServiceFactory>& xNamedPropertyContainerFactory,
202 GraphicObjectType eMapTo,
203 const awt::Size* pRefSize,
204 bool bDataSeries,
205 bool bUseSpecialFillColor,
206 sal_Int32 nSpecialFillColor,
207 bool bOverwriteLabelsForAttributedDataPointsAlso,
208 sal_Int32 nNumberFormat,
209 sal_Int32 nPercentNumberFormat ) :
210 ItemConverter( rPropertySet, rItemPool ),
211 m_bDataSeries( bDataSeries ),
212 m_bOverwriteLabelsForAttributedDataPointsAlso(m_bDataSeries && bOverwriteLabelsForAttributedDataPointsAlso),
213 m_bUseSpecialFillColor(bUseSpecialFillColor),
214 m_nSpecialFillColor(nSpecialFillColor),
215 m_nNumberFormat(nNumberFormat),
216 m_nPercentNumberFormat(nPercentNumberFormat),
217 m_aAvailableLabelPlacements(),
218 m_bForbidPercentValue(true)
220 m_aConverters.emplace_back( new GraphicPropertyItemConverter(
221 rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, eMapTo ));
222 m_aConverters.emplace_back( new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize"));
223 if( bDataSeries )
225 m_aConverters.emplace_back( new StatisticsItemConverter( xChartModel, rPropertySet, rItemPool ));
226 m_aConverters.emplace_back( new SeriesOptionsItemConverter( xChartModel, xContext, rPropertySet, rItemPool ));
229 uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) );
230 uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xSeries ) );
231 bool bFound = false;
232 bool bAmbiguous = false;
233 bool bSwapXAndY = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
234 m_aAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements( xChartType, bSwapXAndY, xSeries );
236 m_bForbidPercentValue = ChartTypeHelper::getAxisType( xChartType, 0 ) != AxisType::CATEGORY;
239 DataPointItemConverter::~DataPointItemConverter()
243 void DataPointItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
245 for( const auto& pConv : m_aConverters )
246 pConv->FillItemSet( rOutItemSet );
248 // own items
249 ItemConverter::FillItemSet( rOutItemSet );
251 if( m_bUseSpecialFillColor )
253 Color aColor(m_nSpecialFillColor);
254 rOutItemSet.Put( XFillColorItem( OUString(), aColor ) );
258 bool DataPointItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
260 bool bResult = false;
262 for( const auto& pConv : m_aConverters )
263 bResult = pConv->ApplyItemSet( rItemSet ) || bResult;
265 // own items
266 return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
269 const sal_uInt16 * DataPointItemConverter::GetWhichPairs() const
271 // must span all used items!
272 if( m_bDataSeries )
273 return nRowWhichPairs;
274 return nDataPointWhichPairs;
277 bool DataPointItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
279 ItemPropertyMapType & rMap( lcl_GetDataPointPropertyMap());
280 ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
282 if( aIt == rMap.end())
283 return false;
285 rOutProperty =(*aIt).second;
286 return true;
289 bool DataPointItemConverter::ApplySpecialItem(
290 sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
292 bool bChanged = false;
294 switch( nWhichId )
296 case SCHATTR_DATADESCR_SHOW_NUMBER:
297 case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
298 case SCHATTR_DATADESCR_SHOW_CATEGORY:
299 case SCHATTR_DATADESCR_SHOW_SYMBOL:
301 const SfxBoolItem & rItem = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId ));
303 uno::Any aOldValue = GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL);
304 chart2::DataPointLabel aLabel;
305 if( aOldValue >>= aLabel )
307 sal_Bool& rValue = (nWhichId==SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : (
308 (nWhichId==SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : (
309 (nWhichId==SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
310 bool bOldValue = rValue;
311 rValue = rItem.GetValue();
312 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
314 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
315 if( bOldValue != bool(rValue) ||
316 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, CHART_UNONAME_LABEL , aOldValue ) )
318 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_LABEL , uno::Any( aLabel ) );
319 bChanged = true;
322 else if( bOldValue != bool(rValue) )
324 GetPropertySet()->setPropertyValue(CHART_UNONAME_LABEL , uno::Any(aLabel));
325 bChanged = true;
329 break;
331 case SID_ATTR_NUMBERFORMAT_VALUE:
332 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: //fall through intended
334 bChanged = lcl_NumberFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
336 break;
338 case SID_ATTR_NUMBERFORMAT_SOURCE:
339 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended
341 bChanged = lcl_UseSourceFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
343 break;
345 case SCHATTR_DATADESCR_SEPARATOR:
347 OUString aNewValue = static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue();
348 OUString aOldValue;
351 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aOldValue;
352 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
354 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
355 if( aOldValue != aNewValue ||
356 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelSeparator" , uno::Any( aOldValue ) ) )
358 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelSeparator" , uno::Any( aNewValue ) );
359 bChanged = true;
362 else if( aOldValue != aNewValue )
364 GetPropertySet()->setPropertyValue( "LabelSeparator" , uno::Any( aNewValue ));
365 bChanged = true;
368 catch( const uno::Exception& )
370 TOOLS_WARN_EXCEPTION("chart2", "" );
373 break;
375 case SCHATTR_DATADESCR_WRAP_TEXT:
380 bool bNew = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
381 bool bOld = false;
382 GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bOld;
383 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
385 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
386 if( bOld!=bNew ||
387 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "TextWordWrap", uno::Any( bOld ) ) )
389 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "TextWordWrap", uno::Any( bNew ) );
390 bChanged = true;
393 else if( bOld!=bNew )
395 GetPropertySet()->setPropertyValue( "TextWordWrap", uno::Any( bNew ));
396 bChanged = true;
399 catch( const uno::Exception& )
401 TOOLS_WARN_EXCEPTION("chart2", "" );
404 break;
406 case SCHATTR_DATADESCR_PLACEMENT:
411 sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
412 sal_Int32 nOld =0;
413 if( !(GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nOld) )
415 if( m_aAvailableLabelPlacements.hasElements() )
416 nOld = m_aAvailableLabelPlacements[0];
418 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
420 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
421 if( nOld!=nNew ||
422 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelPlacement" , uno::Any( nOld ) ) )
424 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelPlacement" , uno::Any( nNew ) );
425 bChanged = true;
428 else if( nOld!=nNew )
430 GetPropertySet()->setPropertyValue( "LabelPlacement" , uno::Any( nNew ));
431 bChanged = true;
434 catch( const uno::Exception& )
436 TOOLS_WARN_EXCEPTION("chart2", "" );
439 break;
441 case SCHATTR_STYLE_SYMBOL:
443 sal_Int32 nStyle =
444 static_cast< const SfxInt32Item & >(
445 rItemSet.Get( nWhichId )).GetValue();
446 chart2::Symbol aSymbol;
448 GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
449 sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol );
451 if( nStyle != nOldStyle )
453 bool bDeleteSymbol = false;
454 switch( nStyle )
456 case SVX_SYMBOLTYPE_NONE:
457 aSymbol.Style = chart2::SymbolStyle_NONE;
458 break;
459 case SVX_SYMBOLTYPE_AUTO:
460 aSymbol.Style = chart2::SymbolStyle_AUTO;
461 break;
462 case SVX_SYMBOLTYPE_BRUSHITEM:
463 aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
464 break;
465 case SVX_SYMBOLTYPE_UNKNOWN:
466 bDeleteSymbol = true;
467 break;
469 default:
470 aSymbol.Style = chart2::SymbolStyle_STANDARD;
471 aSymbol.StandardSymbol = nStyle;
474 if( bDeleteSymbol )
475 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any());
476 else
477 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol ));
478 bChanged = true;
481 break;
483 case SCHATTR_SYMBOL_SIZE:
485 Size aSize = static_cast< const SvxSizeItem & >(
486 rItemSet.Get( nWhichId )).GetSize();
487 chart2::Symbol aSymbol;
489 GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
490 if( aSize.getWidth() != aSymbol.Size.Width ||
491 aSize.getHeight() != aSymbol.Size.Height )
493 aSymbol.Size.Width = aSize.getWidth();
494 aSymbol.Size.Height = aSize.getHeight();
496 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol ));
497 bChanged = true;
500 break;
502 case SCHATTR_SYMBOL_BRUSH:
504 const SvxBrushItem & rBrshItem( static_cast< const SvxBrushItem & >(
505 rItemSet.Get( nWhichId )));
506 uno::Any aXGraphicAny;
507 const Graphic *pGraphic( rBrshItem.GetGraphic());
508 if( pGraphic )
510 uno::Reference< graphic::XGraphic > xGraphic( pGraphic->GetXGraphic());
511 if( xGraphic.is())
513 aXGraphicAny <<= xGraphic;
514 chart2::Symbol aSymbol;
515 GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
516 if( aSymbol.Graphic != xGraphic )
518 aSymbol.Graphic = xGraphic;
519 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol ));
520 bChanged = true;
525 break;
527 case SCHATTR_TEXT_DEGREES:
529 double fValue = static_cast< double >(
530 static_cast< const SfxInt32Item & >(
531 rItemSet.Get( nWhichId )).GetValue()) / 100.0;
532 double fOldValue = 0.0;
533 bool bPropExisted =
534 ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldValue );
536 if( ! bPropExisted || fOldValue != fValue )
538 GetPropertySet()->setPropertyValue( "TextRotation" , uno::Any( fValue ));
539 bChanged = true;
542 break;
545 return bChanged;
548 void DataPointItemConverter::FillSpecialItem(
549 sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
551 switch( nWhichId )
553 case SCHATTR_DATADESCR_SHOW_NUMBER:
554 case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
555 case SCHATTR_DATADESCR_SHOW_CATEGORY:
556 case SCHATTR_DATADESCR_SHOW_SYMBOL:
558 chart2::DataPointLabel aLabel;
559 if (GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel)
561 bool bValue = (nWhichId==SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : (
562 (nWhichId==SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : (
563 (nWhichId==SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
565 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
567 if( m_bOverwriteLabelsForAttributedDataPointsAlso )
569 if( DataSeriesHelper::hasAttributedDataPointDifferentValue(
570 Reference< chart2::XDataSeries >( GetPropertySet(), uno::UNO_QUERY), CHART_UNONAME_LABEL , uno::Any(aLabel) ) )
572 rOutItemSet.InvalidateItem(nWhichId);
577 break;
579 case SID_ATTR_NUMBERFORMAT_VALUE:
581 sal_Int32 nKey = 0;
582 if (!(GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nKey))
583 nKey = m_nNumberFormat;
584 rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
586 break;
588 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:
590 sal_Int32 nKey = 0;
591 if( !(GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ) >>= nKey) )
592 nKey = m_nPercentNumberFormat;
593 rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
595 break;
597 case SID_ATTR_NUMBERFORMAT_SOURCE:
599 bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue();
600 rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
602 break;
603 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
605 bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ).hasValue();
606 rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
608 break;
610 case SCHATTR_DATADESCR_SEPARATOR:
612 OUString aValue;
615 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aValue;
616 rOutItemSet.Put( SfxStringItem( nWhichId, aValue ));
618 catch( const uno::Exception& )
620 TOOLS_WARN_EXCEPTION("chart2", "" );
623 break;
625 case SCHATTR_DATADESCR_WRAP_TEXT:
629 bool bValue = false;
630 GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bValue;
631 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
633 catch( const uno::Exception& )
635 TOOLS_WARN_EXCEPTION("chart2", "" );
638 break;
640 case SCHATTR_DATADESCR_PLACEMENT:
644 sal_Int32 nPlacement=0;
645 if( GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nPlacement )
646 rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement ));
647 else if( m_aAvailableLabelPlacements.hasElements() )
648 rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] ));
650 catch( const uno::Exception& )
652 TOOLS_WARN_EXCEPTION("chart2", "" );
655 break;
657 case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS:
659 rOutItemSet.Put( SfxIntegerListItem( nWhichId, m_aAvailableLabelPlacements ) );
661 break;
663 case SCHATTR_DATADESCR_NO_PERCENTVALUE:
665 rOutItemSet.Put( SfxBoolItem( nWhichId, m_bForbidPercentValue ));
667 break;
669 case SCHATTR_STYLE_SYMBOL:
671 chart2::Symbol aSymbol;
672 if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
673 rOutItemSet.Put( SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) ));
675 break;
677 case SCHATTR_SYMBOL_SIZE:
679 chart2::Symbol aSymbol;
680 if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
681 rOutItemSet.Put(
682 SvxSizeItem( nWhichId, Size( aSymbol.Size.Width, aSymbol.Size.Height ) ));
684 break;
686 case SCHATTR_SYMBOL_BRUSH:
688 chart2::Symbol aSymbol;
689 if(( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
690 && aSymbol.Graphic.is() )
692 rOutItemSet.Put( SvxBrushItem( Graphic( aSymbol.Graphic ), GPOS_MM, SCHATTR_SYMBOL_BRUSH ));
695 break;
697 case SCHATTR_TEXT_DEGREES:
699 double fValue = 0;
701 if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fValue )
703 rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >(
704 ::rtl::math::round( fValue * 100.0 ) ) ));
707 break;
713 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */