tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / controller / itemsetwrapper / TextLabelItemConverter.cxx
blob182e50050f6f6b5fbaf927f62dbd677e454954c0
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 <TextLabelItemConverter.hxx>
21 #include <CharacterPropertyItemConverter.hxx>
22 #include <ChartModel.hxx>
23 #include <ChartType.hxx>
24 #include <ChartTypeHelper.hxx>
25 #include <DataSeries.hxx>
26 #include <DataSeriesHelper.hxx>
27 #include <DataSeriesProperties.hxx>
28 #include <Diagram.hxx>
29 #include <ItemPropertyMap.hxx>
30 #include "SchWhichPairs.hxx"
31 #include <unonames.hxx>
33 #include <editeng/brushitem.hxx>
34 #include <editeng/sizeitem.hxx>
35 #include <svl/eitem.hxx>
36 #include <svl/ilstitem.hxx>
37 #include <svl/intitem.hxx>
38 #include <svl/stritem.hxx>
39 #include <svx/tabline.hxx>
40 #include <svx/sdangitm.hxx>
41 #include <comphelper/diagnose_ex.hxx>
42 #include <vcl/graph.hxx>
43 #include <rtl/math.hxx>
45 #include <com/sun/star/chart/DataLabelPlacement.hpp>
46 #include <com/sun/star/chart2/AxisType.hpp>
47 #include <com/sun/star/chart2/DataPointLabel.hpp>
48 #include <com/sun/star/chart2/Symbol.hpp>
49 #include <com/sun/star/chart2/RelativePosition.hpp>
50 #include <memory>
52 using namespace com::sun::star;
53 using namespace com::sun::star::chart2;
54 using com::sun::star::uno::Reference;
55 using namespace ::chart::DataSeriesProperties;
57 namespace chart::wrapper {
59 namespace {
61 const ItemPropertyMapType& getTextLabelPropertyMap()
63 static ItemPropertyMapType aMap{
64 {XATTR_LINESTYLE, {CHART_UNONAME_LABEL_BORDER_STYLE, 0}},
65 {XATTR_LINEWIDTH, {CHART_UNONAME_LABEL_BORDER_WIDTH, 0}},
66 {XATTR_LINEDASH, {CHART_UNONAME_LABEL_BORDER_DASH, 0}},
67 {XATTR_LINECOLOR, {CHART_UNONAME_LABEL_BORDER_COLOR, 0}},
68 {XATTR_LINETRANSPARENCE, {CHART_UNONAME_LABEL_BORDER_TRANS, 0}}};
69 return aMap;
72 sal_Int32 getSymbolStyleForSymbol( const chart2::Symbol& rSymbol )
74 sal_Int32 nStyle = SVX_SYMBOLTYPE_UNKNOWN;
75 switch (rSymbol.Style)
77 case chart2::SymbolStyle_NONE:
78 nStyle = SVX_SYMBOLTYPE_NONE;
79 break;
80 case chart2::SymbolStyle_AUTO:
81 nStyle = SVX_SYMBOLTYPE_AUTO;
82 break;
83 case chart2::SymbolStyle_GRAPHIC:
84 nStyle = SVX_SYMBOLTYPE_BRUSHITEM;
85 break;
86 case chart2::SymbolStyle_STANDARD:
87 nStyle = rSymbol.StandardSymbol;
88 break;
89 case chart2::SymbolStyle_POLYGON:
90 default:
93 return nStyle;
96 bool numberFormatFromItemToPropertySet(
97 sal_uInt16 nWhichId, const SfxItemSet& rItemSet, const uno::Reference<beans::XPropertySet>& xPropertySet,
98 bool bOverwriteDataPoints )
100 bool bChanged = false;
101 if (!xPropertySet.is())
102 return bChanged;
104 OUString aPropertyName = (nWhichId == SID_ATTR_NUMBERFORMAT_VALUE) ? CHART_UNONAME_NUMFMT : u"PercentageNumberFormat"_ustr;
105 sal_uInt16 nSourceWhich = (nWhichId == SID_ATTR_NUMBERFORMAT_VALUE) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE;
107 if (rItemSet.GetItemState(nSourceWhich) != SfxItemState::SET)
108 return bChanged;
110 uno::Any aValue;
111 bool bUseSourceFormat = static_cast<const SfxBoolItem&>(rItemSet.Get(nSourceWhich)).GetValue();
112 if (!bUseSourceFormat)
114 SfxItemState aState = rItemSet.GetItemState(nWhichId);
115 if (aState == SfxItemState::SET)
117 sal_Int32 nFmt = static_cast<sal_Int32>(
118 static_cast<const SfxUInt32Item&>(
119 rItemSet.Get(nWhichId)).GetValue());
120 aValue <<= nFmt;
122 else
123 return bChanged;
126 uno::Any aOldValue = xPropertySet->getPropertyValue(aPropertyName);
127 if (bOverwriteDataPoints)
129 rtl::Reference<DataSeries> xSeries( dynamic_cast<DataSeries*>(xPropertySet.get()) );
130 if (aValue != aOldValue ||
131 ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, aPropertyName, aOldValue))
133 ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, aPropertyName, aValue);
134 bChanged = true;
137 else if (aOldValue != aValue)
139 xPropertySet->setPropertyValue(aPropertyName, aValue);
140 bChanged = true;
142 return bChanged;
145 bool useSourceFormatFromItemToPropertySet(
146 sal_uInt16 nWhichId, const SfxItemSet& rItemSet, const uno::Reference<beans::XPropertySet>& xPropertySet,
147 bool bOverwriteDataPoints )
149 bool bChanged = false;
150 if (!xPropertySet.is())
151 return bChanged;
152 OUString aPropertyName = (nWhichId == SID_ATTR_NUMBERFORMAT_SOURCE) ? CHART_UNONAME_NUMFMT : u"PercentageNumberFormat"_ustr;
153 sal_uInt16 nFormatWhich = (nWhichId == SID_ATTR_NUMBERFORMAT_SOURCE) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE;
155 if (rItemSet.GetItemState(nWhichId) != SfxItemState::SET)
156 return bChanged;
158 uno::Any aNewValue;
159 bool bUseSourceFormat = static_cast<const SfxBoolItem&>(
160 rItemSet.Get(nWhichId)).GetValue();
161 xPropertySet->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(bUseSourceFormat));
162 if (!bUseSourceFormat)
164 SfxItemState aState = rItemSet.GetItemState(nFormatWhich);
165 if (aState == SfxItemState::SET)
167 sal_Int32 nFormatKey = static_cast<sal_Int32>(
168 static_cast<const SfxUInt32Item&>(
169 rItemSet.Get(nFormatWhich)).GetValue());
170 aNewValue <<= nFormatKey;
172 else
173 return bChanged;
176 uno::Any aOldValue(xPropertySet->getPropertyValue(aPropertyName));
177 if (bOverwriteDataPoints)
179 rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(xPropertySet.get()));
180 if (aNewValue != aOldValue ||
181 ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, aPropertyName, aOldValue))
183 ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, aPropertyName, aNewValue);
184 bChanged = true;
187 else if (aOldValue != aNewValue)
189 xPropertySet->setPropertyValue(aPropertyName, aNewValue);
190 bChanged = true;
193 return bChanged;
196 } // anonymous namespace
198 TextLabelItemConverter::TextLabelItemConverter(
199 const rtl::Reference<::chart::ChartModel>& xChartModel,
200 const uno::Reference<beans::XPropertySet>& rPropertySet,
201 const rtl::Reference<DataSeries>& xSeries,
202 SfxItemPool& rItemPool, const std::optional<awt::Size>& pRefSize,
203 bool bDataSeries, sal_Int32 nNumberFormat, sal_Int32 nPercentNumberFormat ) :
204 ItemConverter(rPropertySet, rItemPool),
205 mnNumberFormat(nNumberFormat),
206 mnPercentNumberFormat(nPercentNumberFormat),
207 mbDataSeries(bDataSeries),
208 mbForbidPercentValue(true),
209 m_xSeries(xSeries)
211 maConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, u"ReferencePageSize"_ustr));
213 rtl::Reference< Diagram > xDiagram(xChartModel->getFirstChartDiagram());
214 rtl::Reference< ChartType > xChartType(xDiagram->getChartTypeOfSeries(xSeries));
215 bool bFound = false;
216 bool bAmbiguous = false;
217 bool bSwapXAndY = xDiagram->getVertical(bFound, bAmbiguous);
218 maAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements(xChartType, bSwapXAndY, xSeries);
220 mbForbidPercentValue = ChartTypeHelper::getAxisType(xChartType, 0) != AxisType::CATEGORY;
223 TextLabelItemConverter::~TextLabelItemConverter()
227 void TextLabelItemConverter::FillItemSet( SfxItemSet& rOutItemSet ) const
229 for( const auto& pConv : maConverters )
230 pConv->FillItemSet( rOutItemSet );
232 // own items
233 ItemConverter::FillItemSet(rOutItemSet);
236 bool TextLabelItemConverter::ApplyItemSet( const SfxItemSet& rItemSet )
238 bool bResult = false;
240 for( const auto& pConv: maConverters )
241 bResult = pConv->ApplyItemSet( rItemSet ) || bResult;
243 // own items
244 return ItemConverter::ApplyItemSet(rItemSet) || bResult;
247 const WhichRangesContainer& TextLabelItemConverter::GetWhichPairs() const
249 // must span all used items!
250 return nTextLabelWhichPairs;
253 bool TextLabelItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId& rOutProperty ) const
255 const ItemPropertyMapType& rMap = getTextLabelPropertyMap();
256 ItemPropertyMapType::const_iterator it = rMap.find(nWhichId);
258 if (it == rMap.end())
259 return false;
261 rOutProperty = it->second;
262 return true;
265 bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet& rItemSet )
267 bool bChanged = false;
269 switch (nWhichId)
271 case SCHATTR_DATADESCR_SHOW_NUMBER:
272 case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
273 case SCHATTR_DATADESCR_SHOW_CATEGORY:
274 case SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME:
275 case SCHATTR_DATADESCR_SHOW_SYMBOL:
277 const SfxBoolItem& rItem = static_cast<const SfxBoolItem&>(rItemSet.Get(nWhichId));
279 uno::Any aOldValue = GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL);
280 chart2::DataPointLabel aLabel;
281 if (aOldValue >>= aLabel)
283 sal_Bool& rValue = (nWhichId == SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : (
284 (nWhichId == SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : (
285 (nWhichId == SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName :
286 (nWhichId == SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME) ? aLabel.ShowSeriesName : aLabel.ShowLegendSymbol));
287 bool bOldValue = rValue;
288 rValue = rItem.GetValue();
289 if (mbDataSeries)
291 rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get()));
292 if (bOldValue != bool(rValue) ||
293 DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, CHART_UNONAME_LABEL, aOldValue))
295 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, CHART_UNONAME_LABEL, uno::Any(aLabel));
296 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any());
297 bChanged = true;
300 else if (bOldValue != bool(rValue))
302 GetPropertySet()->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel));
303 bChanged = true;
307 break;
308 case SID_ATTR_NUMBERFORMAT_VALUE:
309 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: //fall through intended
311 bChanged = numberFormatFromItemToPropertySet(nWhichId, rItemSet, GetPropertySet(), mbDataSeries);
313 break;
314 case SID_ATTR_NUMBERFORMAT_SOURCE:
315 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended
317 bChanged = useSourceFormatFromItemToPropertySet(nWhichId, rItemSet, GetPropertySet(), mbDataSeries);
319 break;
320 case SCHATTR_DATADESCR_SEPARATOR:
322 OUString aNewValue = static_cast<const SfxStringItem&>(rItemSet.Get(nWhichId)).GetValue();
325 OUString aOldValue;
326 GetPropertySet()->getPropertyValue(u"LabelSeparator"_ustr) >>= aOldValue;
327 if (mbDataSeries)
329 rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get()));
330 if (aOldValue != aNewValue ||
331 DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, u"LabelSeparator"_ustr, uno::Any(aOldValue)))
333 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, u"LabelSeparator"_ustr, uno::Any(aNewValue));
334 bChanged = true;
337 else if (aOldValue != aNewValue)
339 GetPropertySet()->setPropertyValue(u"LabelSeparator"_ustr, uno::Any(aNewValue));
340 bChanged = true;
343 catch (const uno::Exception&)
345 TOOLS_WARN_EXCEPTION("chart2", "");
348 break;
349 case SCHATTR_DATADESCR_WRAP_TEXT:
354 bool bNew = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
355 bool bOld = false;
356 GetPropertySet()->getPropertyValue( u"TextWordWrap"_ustr ) >>= bOld;
357 if( mbDataSeries )
359 rtl::Reference< DataSeries > xSeries( dynamic_cast<DataSeries*>(GetPropertySet().get()) );
360 if( bOld!=bNew ||
361 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, u"TextWordWrap"_ustr, uno::Any( bOld ) ) )
363 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, u"TextWordWrap"_ustr, uno::Any( bNew ) );
364 bChanged = true;
367 else if( bOld!=bNew )
369 GetPropertySet()->setPropertyValue( u"TextWordWrap"_ustr, uno::Any( bNew ));
370 bChanged = true;
373 catch( const uno::Exception& )
375 TOOLS_WARN_EXCEPTION("chart2", "" );
378 break;
379 case SCHATTR_DATADESCR_PLACEMENT:
383 sal_Int32 nNew = static_cast<const SfxInt32Item&>(rItemSet.Get(nWhichId)).GetValue();
384 sal_Int32 nOld = -1;
385 RelativePosition aCustomLabelPosition;
386 GetPropertySet()->getPropertyValue(u"LabelPlacement"_ustr) >>= nOld;
387 if (mbDataSeries)
389 rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get()));
390 if (nOld != nNew ||
391 DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, u"LabelPlacement"_ustr, uno::Any(nOld)))
393 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, u"LabelPlacement"_ustr, uno::Any(nNew));
394 bChanged = true;
397 else if (nOld != nNew || (GetPropertySet()->getPropertyValue(u"CustomLabelPosition"_ustr) >>= aCustomLabelPosition))
399 GetPropertySet()->setPropertyValue(u"LabelPlacement"_ustr, uno::Any(nNew));
400 GetPropertySet()->setPropertyValue(u"CustomLabelPosition"_ustr, uno::Any());
401 GetPropertySet()->setPropertyValue(u"CustomLabelSize"_ustr, uno::Any());
402 bChanged = true;
405 catch (const uno::Exception&)
407 TOOLS_WARN_EXCEPTION("chart2", "" );
410 break;
411 case SCHATTR_STYLE_SYMBOL:
413 sal_Int32 nStyle =
414 static_cast<const SfxInt32Item&>(
415 rItemSet.Get(nWhichId)).GetValue();
416 chart2::Symbol aSymbol;
418 GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol;
419 sal_Int32 nOldStyle = getSymbolStyleForSymbol(aSymbol);
421 if (nStyle != nOldStyle)
423 bool bDeleteSymbol = false;
424 switch (nStyle)
426 case SVX_SYMBOLTYPE_NONE:
427 aSymbol.Style = chart2::SymbolStyle_NONE;
428 break;
429 case SVX_SYMBOLTYPE_AUTO:
430 aSymbol.Style = chart2::SymbolStyle_AUTO;
431 break;
432 case SVX_SYMBOLTYPE_BRUSHITEM:
433 aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
434 break;
435 case SVX_SYMBOLTYPE_UNKNOWN:
436 bDeleteSymbol = true;
437 break;
439 default:
440 aSymbol.Style = chart2::SymbolStyle_STANDARD;
441 aSymbol.StandardSymbol = nStyle;
444 if (bDeleteSymbol)
445 GetPropertySet()->setPropertyValue(u"Symbol"_ustr, uno::Any());
446 else
447 GetPropertySet()->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol));
448 bChanged = true;
451 break;
452 case SCHATTR_SYMBOL_SIZE:
454 Size aSize = static_cast<const SvxSizeItem&>(
455 rItemSet.Get(nWhichId)).GetSize();
456 chart2::Symbol aSymbol;
458 GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol;
459 if (aSize.getWidth() != aSymbol.Size.Width ||
460 aSize.getHeight() != aSymbol.Size.Height)
462 aSymbol.Size.Width = aSize.getWidth();
463 aSymbol.Size.Height = aSize.getHeight();
465 GetPropertySet()->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol));
466 bChanged = true;
469 break;
470 case SCHATTR_SYMBOL_BRUSH:
472 const SvxBrushItem& rBrshItem(static_cast<const SvxBrushItem&>(
473 rItemSet.Get(nWhichId)));
474 uno::Any aXGraphicAny;
475 const Graphic* pGraphic(rBrshItem.GetGraphic());
476 if (pGraphic)
478 uno::Reference<graphic::XGraphic> xGraphic(pGraphic->GetXGraphic());
479 if (xGraphic.is())
481 aXGraphicAny <<= xGraphic;
482 chart2::Symbol aSymbol;
483 GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol;
484 if (aSymbol.Graphic != xGraphic)
486 aSymbol.Graphic = std::move(xGraphic);
487 GetPropertySet()->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol));
488 bChanged = true;
493 break;
494 case SCHATTR_TEXT_DEGREES:
496 double fValue = static_cast<double>(
497 static_cast<const SdrAngleItem&>(
498 rItemSet.Get(nWhichId)).GetValue().get()) / 100.0;
499 double fOldValue = 0.0;
500 bool bPropExisted =
501 (GetPropertySet()->getPropertyValue(u"TextRotation"_ustr) >>= fOldValue);
503 if (!bPropExisted || fOldValue != fValue)
505 GetPropertySet()->setPropertyValue(u"TextRotation"_ustr, uno::Any(fValue));
506 bChanged = true;
509 break;
510 case SCHATTR_DATADESCR_CUSTOM_LEADER_LINES:
514 bool bNew = static_cast<const SfxBoolItem&>(rItemSet.Get(nWhichId)).GetValue();
515 bool bOld = true;
516 if( (m_xSeries->getFastPropertyValue(PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES) >>= bOld) && bOld != bNew )
518 m_xSeries->setFastPropertyValue(PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES, uno::Any(bNew));
519 bChanged = true;
522 catch (const uno::Exception&)
524 TOOLS_WARN_EXCEPTION("chart2", "");
527 break;
530 return bChanged;
533 void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& rOutItemSet ) const
535 switch (nWhichId)
537 case SCHATTR_DATADESCR_SHOW_NUMBER:
538 case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
539 case SCHATTR_DATADESCR_SHOW_CATEGORY:
540 case SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME:
541 case SCHATTR_DATADESCR_SHOW_SYMBOL:
543 chart2::DataPointLabel aLabel;
544 if (GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel)
546 bool bValue = (nWhichId == SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : (
547 (nWhichId == SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : (
548 (nWhichId == SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : (
549 (nWhichId == SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME) ? aLabel.ShowSeriesName : aLabel.ShowLegendSymbol)));
551 rOutItemSet.Put(SfxBoolItem(nWhichId, bValue));
553 if (mbDataSeries)
555 if (DataSeriesHelper::hasAttributedDataPointDifferentValue(
556 dynamic_cast<DataSeries*>(GetPropertySet().get()), CHART_UNONAME_LABEL, uno::Any(aLabel)))
558 rOutItemSet.InvalidateItem(nWhichId);
563 break;
564 case SID_ATTR_NUMBERFORMAT_VALUE:
566 sal_Int32 nKey = 0;
567 if (!(GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nKey))
568 nKey = mnNumberFormat;
569 rOutItemSet.Put(SfxUInt32Item(nWhichId, nKey));
571 break;
572 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:
574 sal_Int32 nKey = 0;
575 if (!(GetPropertySet()->getPropertyValue(u"PercentageNumberFormat"_ustr) >>= nKey))
576 nKey = mnPercentNumberFormat;
577 rOutItemSet.Put(SfxUInt32Item(nWhichId, nKey));
579 break;
580 case SID_ATTR_NUMBERFORMAT_SOURCE:
582 bool bUseSourceFormat = false;
585 GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
587 catch (const uno::Exception&)
589 TOOLS_WARN_EXCEPTION("chart2", "");
591 bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue() && !bUseSourceFormat;
592 rOutItemSet.Put(SfxBoolItem(nWhichId, !bNumberFormatIsSet));
594 break;
595 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
597 bool bUseSourceFormat = false;
600 GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
602 catch (const uno::Exception&)
604 TOOLS_WARN_EXCEPTION("chart2", "");
606 bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(u"PercentageNumberFormat"_ustr).hasValue() && !bUseSourceFormat;
607 rOutItemSet.Put(SfxBoolItem(nWhichId, !bNumberFormatIsSet));
609 break;
610 case SCHATTR_DATADESCR_SEPARATOR:
614 OUString aValue;
615 GetPropertySet()->getPropertyValue(u"LabelSeparator"_ustr) >>= aValue;
616 rOutItemSet.Put(SfxStringItem(nWhichId, aValue));
618 catch (const uno::Exception&)
620 TOOLS_WARN_EXCEPTION("chart2", "" );
623 break;
624 case SCHATTR_DATADESCR_WRAP_TEXT:
628 bool bValue = false;
629 GetPropertySet()->getPropertyValue( u"TextWordWrap"_ustr ) >>= bValue;
630 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
632 catch( const uno::Exception& )
634 TOOLS_WARN_EXCEPTION("chart2", "" );
637 break;
638 case SCHATTR_DATADESCR_PLACEMENT:
642 sal_Int32 nPlacement = 0;
643 RelativePosition aCustomLabelPosition;
644 if (!mbDataSeries && (GetPropertySet()->getPropertyValue(u"CustomLabelPosition"_ustr) >>= aCustomLabelPosition))
645 rOutItemSet.Put(SfxInt32Item(nWhichId, css::chart::DataLabelPlacement::CUSTOM));
646 else if (GetPropertySet()->getPropertyValue(u"LabelPlacement"_ustr) >>= nPlacement)
647 rOutItemSet.Put(SfxInt32Item(nWhichId, nPlacement));
648 else if (maAvailableLabelPlacements.hasElements())
649 rOutItemSet.Put(SfxInt32Item(nWhichId, maAvailableLabelPlacements[0]));
651 catch (const uno::Exception&)
653 TOOLS_WARN_EXCEPTION("chart2", "" );
656 break;
657 case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS:
659 rOutItemSet.Put(SfxIntegerListItem(nWhichId, maAvailableLabelPlacements));
661 break;
662 case SCHATTR_DATADESCR_NO_PERCENTVALUE:
664 rOutItemSet.Put(SfxBoolItem(nWhichId, mbForbidPercentValue));
666 break;
667 case SCHATTR_DATADESCR_CUSTOM_LEADER_LINES:
671 bool bValue = true;
672 if( m_xSeries->getFastPropertyValue( PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES ) >>= bValue )
673 rOutItemSet.Put(SfxBoolItem(nWhichId, bValue));
675 catch (const uno::Exception&)
677 TOOLS_WARN_EXCEPTION("chart2", "");
680 break;
681 case SCHATTR_STYLE_SYMBOL:
683 chart2::Symbol aSymbol;
684 if (GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol)
685 rOutItemSet.Put(SfxInt32Item(nWhichId, getSymbolStyleForSymbol(aSymbol)));
687 break;
688 case SCHATTR_SYMBOL_SIZE:
690 chart2::Symbol aSymbol;
691 if (GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol)
692 rOutItemSet.Put(
693 SvxSizeItem(nWhichId, Size(aSymbol.Size.Width, aSymbol.Size.Height)));
695 break;
696 case SCHATTR_SYMBOL_BRUSH:
698 chart2::Symbol aSymbol;
699 if ((GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol)
700 && aSymbol.Graphic.is())
702 rOutItemSet.Put(
703 SvxBrushItem(Graphic(aSymbol.Graphic), GPOS_MM, SCHATTR_SYMBOL_BRUSH));
706 break;
707 case SCHATTR_TEXT_DEGREES:
709 double fValue = 0;
711 if (GetPropertySet()->getPropertyValue(u"TextRotation"_ustr) >>= fValue)
713 rOutItemSet.Put(
714 SdrAngleItem(SCHATTR_TEXT_DEGREES, Degree100(static_cast<sal_Int32>(rtl::math::round(fValue * 100.0)))));
717 break;
723 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */