nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / source / controller / itemsetwrapper / TextLabelItemConverter.cxx
blob1ee04136f45c80c5785d81f4fb89d1c22d402afa
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 <ChartModelHelper.hxx>
23 #include <ChartTypeHelper.hxx>
24 #include <DataSeriesHelper.hxx>
25 #include <DiagramHelper.hxx>
26 #include <ItemPropertyMap.hxx>
27 #include "SchWhichPairs.hxx"
28 #include <unonames.hxx>
30 #include <editeng/brushitem.hxx>
31 #include <editeng/sizeitem.hxx>
32 #include <svl/eitem.hxx>
33 #include <svl/ilstitem.hxx>
34 #include <svl/intitem.hxx>
35 #include <svl/stritem.hxx>
36 #include <svx/tabline.hxx>
37 #include <tools/diagnose_ex.h>
38 #include <vcl/graph.hxx>
39 #include <rtl/math.hxx>
41 #include <com/sun/star/chart/DataLabelPlacement.hpp>
42 #include <com/sun/star/chart2/AxisType.hpp>
43 #include <com/sun/star/chart2/DataPointLabel.hpp>
44 #include <com/sun/star/chart2/Symbol.hpp>
45 #include <com/sun/star/chart2/RelativePosition.hpp>
46 #include <com/sun/star/frame/XModel.hpp>
47 #include <memory>
49 using namespace com::sun::star;
50 using namespace com::sun::star::chart2;
51 using com::sun::star::uno::Reference;
53 namespace chart::wrapper {
55 namespace {
57 const ItemPropertyMapType& getTextLabelPropertyMap()
59 static ItemPropertyMapType aMap{
60 {XATTR_LINESTYLE, {CHART_UNONAME_LABEL_BORDER_STYLE, 0}},
61 {XATTR_LINEWIDTH, {CHART_UNONAME_LABEL_BORDER_WIDTH, 0}},
62 {XATTR_LINEDASH, {CHART_UNONAME_LABEL_BORDER_DASH, 0}},
63 {XATTR_LINECOLOR, {CHART_UNONAME_LABEL_BORDER_COLOR, 0}},
64 {XATTR_LINETRANSPARENCE, {CHART_UNONAME_LABEL_BORDER_TRANS, 0}}};
65 return aMap;
68 sal_Int32 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;
85 case chart2::SymbolStyle_POLYGON:
86 default:
89 return nStyle;
92 bool numberFormatFromItemToPropertySet(
93 sal_uInt16 nWhichId, const SfxItemSet& rItemSet, const uno::Reference<beans::XPropertySet>& xPropertySet,
94 bool bOverwriteDataPoints )
96 bool bChanged = false;
97 if (!xPropertySet.is())
98 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&>(rItemSet.Get(nSourceWhich)).GetValue();
108 if (!bUseSourceFormat)
110 SfxItemState aState = rItemSet.GetItemState(nWhichId);
111 if (aState == SfxItemState::SET)
113 sal_Int32 nFmt = static_cast<sal_Int32>(
114 static_cast<const SfxUInt32Item&>(
115 rItemSet.Get(nWhichId)).GetValue());
116 aValue <<= nFmt;
118 else
119 return bChanged;
122 uno::Any aOldValue = xPropertySet->getPropertyValue(aPropertyName);
123 if (bOverwriteDataPoints)
125 Reference<chart2::XDataSeries> xSeries(xPropertySet, uno::UNO_QUERY);
126 if (aValue != aOldValue ||
127 ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, aPropertyName, aOldValue))
129 ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, aPropertyName, aValue);
130 bChanged = true;
133 else if (aOldValue != aValue)
135 xPropertySet->setPropertyValue(aPropertyName, aValue);
136 bChanged = true;
138 return bChanged;
141 bool useSourceFormatFromItemToPropertySet(
142 sal_uInt16 nWhichId, const SfxItemSet& rItemSet, const uno::Reference<beans::XPropertySet>& xPropertySet,
143 bool bOverwriteDataPoints )
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 (bOverwriteDataPoints)
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 TextLabelItemConverter::TextLabelItemConverter(
195 const uno::Reference<frame::XModel>& xChartModel,
196 const uno::Reference<beans::XPropertySet>& rPropertySet,
197 const uno::Reference<XDataSeries>& xSeries,
198 SfxItemPool& rItemPool, const awt::Size* pRefSize,
199 bool bDataSeries, sal_Int32 nNumberFormat, sal_Int32 nPercentNumberFormat ) :
200 ItemConverter(rPropertySet, rItemPool),
201 mnNumberFormat(nNumberFormat),
202 mnPercentNumberFormat(nPercentNumberFormat),
203 mbDataSeries(bDataSeries),
204 mbForbidPercentValue(true),
205 m_xSeries(xSeries)
207 maConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize"));
209 uno::Reference<XDiagram> xDiagram(ChartModelHelper::findDiagram(xChartModel));
210 uno::Reference<XChartType> xChartType(DiagramHelper::getChartTypeOfSeries(xDiagram, xSeries));
211 bool bFound = false;
212 bool bAmbiguous = false;
213 bool bSwapXAndY = DiagramHelper::getVertical(xDiagram, bFound, bAmbiguous);
214 maAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements(xChartType, bSwapXAndY, xSeries);
216 mbForbidPercentValue = ChartTypeHelper::getAxisType(xChartType, 0) != AxisType::CATEGORY;
219 TextLabelItemConverter::~TextLabelItemConverter()
223 void TextLabelItemConverter::FillItemSet( SfxItemSet& rOutItemSet ) const
225 for( const auto& pConv : maConverters )
226 pConv->FillItemSet( rOutItemSet );
228 // own items
229 ItemConverter::FillItemSet(rOutItemSet);
232 bool TextLabelItemConverter::ApplyItemSet( const SfxItemSet& rItemSet )
234 bool bResult = false;
236 for( const auto& pConv: maConverters )
237 bResult = pConv->ApplyItemSet( rItemSet ) || bResult;
239 // own items
240 return ItemConverter::ApplyItemSet(rItemSet) || bResult;
243 const sal_uInt16* TextLabelItemConverter::GetWhichPairs() const
245 // must span all used items!
246 return nTextLabelWhichPairs;
249 bool TextLabelItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId& rOutProperty ) const
251 const ItemPropertyMapType& rMap = getTextLabelPropertyMap();
252 ItemPropertyMapType::const_iterator it = rMap.find(nWhichId);
254 if (it == rMap.end())
255 return false;
257 rOutProperty = it->second;
258 return true;
261 bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet& rItemSet )
263 bool bChanged = false;
265 switch (nWhichId)
267 case SCHATTR_DATADESCR_SHOW_NUMBER:
268 case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
269 case SCHATTR_DATADESCR_SHOW_CATEGORY:
270 case SCHATTR_DATADESCR_SHOW_SYMBOL:
272 const SfxBoolItem& rItem = static_cast<const SfxBoolItem&>(rItemSet.Get(nWhichId));
274 uno::Any aOldValue = GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL);
275 chart2::DataPointLabel aLabel;
276 if (aOldValue >>= aLabel)
278 sal_Bool& rValue = (nWhichId == SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : (
279 (nWhichId == SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : (
280 (nWhichId == SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol));
281 bool bOldValue = rValue;
282 rValue = rItem.GetValue();
283 if (mbDataSeries)
285 Reference<chart2::XDataSeries> xSeries(GetPropertySet(), uno::UNO_QUERY);
286 if (bOldValue != bool(rValue) ||
287 DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, CHART_UNONAME_LABEL, aOldValue))
289 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, CHART_UNONAME_LABEL, uno::Any(aLabel));
290 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any());
291 bChanged = true;
294 else if (bOldValue != bool(rValue))
296 GetPropertySet()->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel));
297 bChanged = true;
301 break;
302 case SID_ATTR_NUMBERFORMAT_VALUE:
303 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: //fall through intended
305 bChanged = numberFormatFromItemToPropertySet(nWhichId, rItemSet, GetPropertySet(), mbDataSeries);
307 break;
308 case SID_ATTR_NUMBERFORMAT_SOURCE:
309 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended
311 bChanged = useSourceFormatFromItemToPropertySet(nWhichId, rItemSet, GetPropertySet(), mbDataSeries);
313 break;
314 case SCHATTR_DATADESCR_SEPARATOR:
316 OUString aNewValue = static_cast<const SfxStringItem&>(rItemSet.Get(nWhichId)).GetValue();
319 OUString aOldValue;
320 GetPropertySet()->getPropertyValue("LabelSeparator") >>= aOldValue;
321 if (mbDataSeries)
323 Reference<chart2::XDataSeries> xSeries(GetPropertySet(), uno::UNO_QUERY);
324 if (aOldValue != aNewValue ||
325 DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, "LabelSeparator", uno::Any(aOldValue)))
327 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, "LabelSeparator", uno::Any(aNewValue));
328 bChanged = true;
331 else if (aOldValue != aNewValue)
333 GetPropertySet()->setPropertyValue("LabelSeparator", uno::Any(aNewValue));
334 bChanged = true;
337 catch (const uno::Exception&)
339 TOOLS_WARN_EXCEPTION("chart2", "");
342 break;
343 case SCHATTR_DATADESCR_WRAP_TEXT:
348 bool bNew = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
349 bool bOld = false;
350 GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bOld;
351 if( mbDataSeries )
353 Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
354 if( bOld!=bNew ||
355 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "TextWordWrap", uno::Any( bOld ) ) )
357 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "TextWordWrap", uno::Any( bNew ) );
358 bChanged = true;
361 else if( bOld!=bNew )
363 GetPropertySet()->setPropertyValue( "TextWordWrap", uno::Any( bNew ));
364 bChanged = true;
367 catch( const uno::Exception& )
369 TOOLS_WARN_EXCEPTION("chart2", "" );
372 break;
373 case SCHATTR_DATADESCR_PLACEMENT:
377 sal_Int32 nNew = static_cast<const SfxInt32Item&>(rItemSet.Get(nWhichId)).GetValue();
378 sal_Int32 nOld = -1;
379 RelativePosition aCustomLabelPosition;
380 GetPropertySet()->getPropertyValue("LabelPlacement") >>= nOld;
381 if (mbDataSeries)
383 Reference<chart2::XDataSeries> xSeries(GetPropertySet(), uno::UNO_QUERY);
384 if (nOld != nNew ||
385 DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, "LabelPlacement", uno::Any(nOld)))
387 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, "LabelPlacement", uno::Any(nNew));
388 bChanged = true;
391 else if (nOld != nNew || (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition))
393 GetPropertySet()->setPropertyValue("LabelPlacement", uno::Any(nNew));
394 GetPropertySet()->setPropertyValue("CustomLabelPosition", uno::Any());
395 bChanged = true;
398 catch (const uno::Exception&)
400 TOOLS_WARN_EXCEPTION("chart2", "" );
403 break;
404 case SCHATTR_STYLE_SYMBOL:
406 sal_Int32 nStyle =
407 static_cast<const SfxInt32Item&>(
408 rItemSet.Get(nWhichId)).GetValue();
409 chart2::Symbol aSymbol;
411 GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol;
412 sal_Int32 nOldStyle = getSymbolStyleForSymbol(aSymbol);
414 if (nStyle != nOldStyle)
416 bool bDeleteSymbol = false;
417 switch (nStyle)
419 case SVX_SYMBOLTYPE_NONE:
420 aSymbol.Style = chart2::SymbolStyle_NONE;
421 break;
422 case SVX_SYMBOLTYPE_AUTO:
423 aSymbol.Style = chart2::SymbolStyle_AUTO;
424 break;
425 case SVX_SYMBOLTYPE_BRUSHITEM:
426 aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
427 break;
428 case SVX_SYMBOLTYPE_UNKNOWN:
429 bDeleteSymbol = true;
430 break;
432 default:
433 aSymbol.Style = chart2::SymbolStyle_STANDARD;
434 aSymbol.StandardSymbol = nStyle;
437 if (bDeleteSymbol)
438 GetPropertySet()->setPropertyValue("Symbol", uno::Any());
439 else
440 GetPropertySet()->setPropertyValue("Symbol", uno::Any(aSymbol));
441 bChanged = true;
444 break;
445 case SCHATTR_SYMBOL_SIZE:
447 Size aSize = static_cast<const SvxSizeItem&>(
448 rItemSet.Get(nWhichId)).GetSize();
449 chart2::Symbol aSymbol;
451 GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol;
452 if (aSize.getWidth() != aSymbol.Size.Width ||
453 aSize.getHeight() != aSymbol.Size.Height)
455 aSymbol.Size.Width = aSize.getWidth();
456 aSymbol.Size.Height = aSize.getHeight();
458 GetPropertySet()->setPropertyValue("Symbol", uno::Any(aSymbol));
459 bChanged = true;
462 break;
463 case SCHATTR_SYMBOL_BRUSH:
465 const SvxBrushItem& rBrshItem(static_cast<const SvxBrushItem&>(
466 rItemSet.Get(nWhichId)));
467 uno::Any aXGraphicAny;
468 const Graphic* pGraphic(rBrshItem.GetGraphic());
469 if (pGraphic)
471 uno::Reference<graphic::XGraphic> xGraphic(pGraphic->GetXGraphic());
472 if (xGraphic.is())
474 aXGraphicAny <<= xGraphic;
475 chart2::Symbol aSymbol;
476 GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol;
477 if (aSymbol.Graphic != xGraphic)
479 aSymbol.Graphic = xGraphic;
480 GetPropertySet()->setPropertyValue("Symbol", uno::Any(aSymbol));
481 bChanged = true;
486 break;
487 case SCHATTR_TEXT_DEGREES:
489 double fValue = static_cast<double>(
490 static_cast<const SfxInt32Item&>(
491 rItemSet.Get(nWhichId)).GetValue()) / 100.0;
492 double fOldValue = 0.0;
493 bool bPropExisted =
494 (GetPropertySet()->getPropertyValue("TextRotation") >>= fOldValue);
496 if (!bPropExisted || fOldValue != fValue)
498 GetPropertySet()->setPropertyValue("TextRotation", uno::Any(fValue));
499 bChanged = true;
502 break;
503 case SCHATTR_DATADESCR_CUSTOM_LEADER_LINES:
507 bool bNew = static_cast<const SfxBoolItem&>(rItemSet.Get(nWhichId)).GetValue();
508 bool bOld = true;
509 Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY);
510 if( (xSeriesProp->getPropertyValue("ShowCustomLeaderLines") >>= bOld) && bOld != bNew )
512 xSeriesProp->setPropertyValue("ShowCustomLeaderLines", uno::Any(bNew));
513 bChanged = true;
516 catch (const uno::Exception&)
518 TOOLS_WARN_EXCEPTION("chart2", "");
521 break;
524 return bChanged;
527 void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& rOutItemSet ) const
529 switch (nWhichId)
531 case SCHATTR_DATADESCR_SHOW_NUMBER:
532 case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
533 case SCHATTR_DATADESCR_SHOW_CATEGORY:
534 case SCHATTR_DATADESCR_SHOW_SYMBOL:
536 chart2::DataPointLabel aLabel;
537 if (GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel)
539 bool bValue = (nWhichId == SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : (
540 (nWhichId == SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : (
541 (nWhichId == SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol));
543 rOutItemSet.Put(SfxBoolItem(nWhichId, bValue));
545 if (mbDataSeries)
547 if (DataSeriesHelper::hasAttributedDataPointDifferentValue(
548 Reference<chart2::XDataSeries>(GetPropertySet(), uno::UNO_QUERY), CHART_UNONAME_LABEL, uno::Any(aLabel)))
550 rOutItemSet.InvalidateItem(nWhichId);
555 break;
556 case SID_ATTR_NUMBERFORMAT_VALUE:
558 sal_Int32 nKey = 0;
559 if (!(GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nKey))
560 nKey = mnNumberFormat;
561 rOutItemSet.Put(SfxUInt32Item(nWhichId, nKey));
563 break;
564 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:
566 sal_Int32 nKey = 0;
567 if (!(GetPropertySet()->getPropertyValue("PercentageNumberFormat") >>= nKey))
568 nKey = mnPercentNumberFormat;
569 rOutItemSet.Put(SfxUInt32Item(nWhichId, nKey));
571 break;
572 case SID_ATTR_NUMBERFORMAT_SOURCE:
574 bool bUseSourceFormat = false;
577 GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
579 catch (const uno::Exception&)
581 TOOLS_WARN_EXCEPTION("chart2", "");
583 bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue() && !bUseSourceFormat;
584 rOutItemSet.Put(SfxBoolItem(nWhichId, !bNumberFormatIsSet));
586 break;
587 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
589 bool bUseSourceFormat = false;
592 GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
594 catch (const uno::Exception&)
596 TOOLS_WARN_EXCEPTION("chart2", "");
598 bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue("PercentageNumberFormat").hasValue() && !bUseSourceFormat;
599 rOutItemSet.Put(SfxBoolItem(nWhichId, !bNumberFormatIsSet));
601 break;
602 case SCHATTR_DATADESCR_SEPARATOR:
606 OUString aValue;
607 GetPropertySet()->getPropertyValue("LabelSeparator") >>= aValue;
608 rOutItemSet.Put(SfxStringItem(nWhichId, aValue));
610 catch (const uno::Exception&)
612 TOOLS_WARN_EXCEPTION("chart2", "" );
615 break;
616 case SCHATTR_DATADESCR_WRAP_TEXT:
620 bool bValue = false;
621 GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bValue;
622 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
624 catch( const uno::Exception& )
626 TOOLS_WARN_EXCEPTION("chart2", "" );
629 break;
630 case SCHATTR_DATADESCR_PLACEMENT:
634 sal_Int32 nPlacement = 0;
635 RelativePosition aCustomLabelPosition;
636 if (!mbDataSeries && (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition))
637 rOutItemSet.Put(SfxInt32Item(nWhichId, css::chart::DataLabelPlacement::CUSTOM));
638 else if (GetPropertySet()->getPropertyValue("LabelPlacement") >>= nPlacement)
639 rOutItemSet.Put(SfxInt32Item(nWhichId, nPlacement));
640 else if (maAvailableLabelPlacements.hasElements())
641 rOutItemSet.Put(SfxInt32Item(nWhichId, maAvailableLabelPlacements[0]));
643 catch (const uno::Exception&)
645 TOOLS_WARN_EXCEPTION("chart2", "" );
648 break;
649 case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS:
651 rOutItemSet.Put(SfxIntegerListItem(nWhichId, maAvailableLabelPlacements));
653 break;
654 case SCHATTR_DATADESCR_NO_PERCENTVALUE:
656 rOutItemSet.Put(SfxBoolItem(nWhichId, mbForbidPercentValue));
658 break;
659 case SCHATTR_DATADESCR_CUSTOM_LEADER_LINES:
663 bool bValue = true;
664 Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY);
665 if( xSeriesProp->getPropertyValue( "ShowCustomLeaderLines" ) >>= bValue )
666 rOutItemSet.Put(SfxBoolItem(nWhichId, bValue));
668 catch (const uno::Exception&)
670 TOOLS_WARN_EXCEPTION("chart2", "");
673 break;
674 case SCHATTR_STYLE_SYMBOL:
676 chart2::Symbol aSymbol;
677 if (GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol)
678 rOutItemSet.Put(SfxInt32Item(nWhichId, getSymbolStyleForSymbol(aSymbol)));
680 break;
681 case SCHATTR_SYMBOL_SIZE:
683 chart2::Symbol aSymbol;
684 if (GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol)
685 rOutItemSet.Put(
686 SvxSizeItem(nWhichId, Size(aSymbol.Size.Width, aSymbol.Size.Height)));
688 break;
689 case SCHATTR_SYMBOL_BRUSH:
691 chart2::Symbol aSymbol;
692 if ((GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol)
693 && aSymbol.Graphic.is())
695 rOutItemSet.Put(
696 SvxBrushItem(Graphic(aSymbol.Graphic), GPOS_MM, SCHATTR_SYMBOL_BRUSH));
699 break;
700 case SCHATTR_TEXT_DEGREES:
702 double fValue = 0;
704 if (GetPropertySet()->getPropertyValue("TextRotation") >>= fValue)
706 rOutItemSet.Put(
707 SfxInt32Item(nWhichId, static_cast<sal_Int32>(rtl::math::round(fValue * 100.0))));
710 break;
716 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */