Debian Codegraph @

chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx

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