LibreOffice Module chart2 (master) 1
DataPointItemConverter.cxx
Go to the documentation of this file.
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
21#include "SchWhichPairs.hxx"
22#include <ItemPropertyMap.hxx>
23
28#include <DataSeries.hxx>
29#include <DataSeriesHelper.hxx>
31#include <DiagramHelper.hxx>
32#include <Diagram.hxx>
33#include <ChartModel.hxx>
34#include <ChartModelHelper.hxx>
35#include <ChartType.hxx>
36#include <ChartTypeHelper.hxx>
37#include <unonames.hxx>
38
39#include <com/sun/star/chart/DataLabelPlacement.hpp>
40#include <com/sun/star/chart2/AxisType.hpp>
41#include <com/sun/star/chart2/DataPointLabel.hpp>
42#include <com/sun/star/chart2/Symbol.hpp>
43#include <com/sun/star/chart2/RelativePosition.hpp>
44#include <com/sun/star/chart2/XDataSeries.hpp>
45#include <com/sun/star/beans/XPropertySet.hpp>
46
48#include <svx/xflclit.hxx>
49#include <svl/eitem.hxx>
50#include <svl/intitem.hxx>
51#include <editeng/sizeitem.hxx>
52#include <svl/stritem.hxx>
53#include <editeng/brushitem.hxx>
54#include <svl/ilstitem.hxx>
55#include <svx/sdangitm.hxx>
57#include <vcl/graph.hxx>
58#include <rtl/math.hxx>
59
60#include <svx/tabline.hxx>
61
62#include <memory>
63
64using namespace ::com::sun::star;
65using namespace ::com::sun::star::chart2;
66using namespace ::chart::DataSeriesProperties;
67using ::com::sun::star::uno::Reference;
68
69namespace chart::wrapper {
70
71namespace {
72
73ItemPropertyMapType & lcl_GetDataPointPropertyMap()
74{
75 static ItemPropertyMapType aDataPointPropertyMap{
76 {SCHATTR_STYLE_SHAPE, {"Geometry3D", 0}}};
77 return aDataPointPropertyMap;
78};
79
80sal_Int32 lcl_getSymbolStyleForSymbol( const chart2::Symbol & rSymbol )
81{
82 sal_Int32 nStyle = SVX_SYMBOLTYPE_UNKNOWN;
83 switch( rSymbol.Style )
84 {
85 case chart2::SymbolStyle_NONE:
86 nStyle = SVX_SYMBOLTYPE_NONE;
87 break;
88 case chart2::SymbolStyle_AUTO:
89 nStyle = SVX_SYMBOLTYPE_AUTO;
90 break;
91 case chart2::SymbolStyle_GRAPHIC:
93 break;
94 case chart2::SymbolStyle_STANDARD:
95 nStyle = rSymbol.StandardSymbol;
96 break;
97
98 case chart2::SymbolStyle_POLYGON:
99 // to avoid warning
100 case chart2::SymbolStyle::SymbolStyle_MAKE_FIXED_SIZE:
101 // nothing
102 break;
103 }
104 return nStyle;
105}
106
107bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso )
108{
109 bool bChanged = false;
110 if( !xPropertySet.is() )
111 return bChanged;
112 OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_VALUE) ? OUString(CHART_UNONAME_NUMFMT) : OUString( "PercentageNumberFormat" );
113 sal_uInt16 nSourceWhich = (nWhichId==SID_ATTR_NUMBERFORMAT_VALUE) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE;
114
115 if( rItemSet.GetItemState( nSourceWhich ) != SfxItemState::SET )
116 return bChanged;
117
118 uno::Any aValue;
119 bool bUseSourceFormat = static_cast< const SfxBoolItem & >(
120 rItemSet.Get( nSourceWhich )).GetValue();
121 if( !bUseSourceFormat )
122 {
123 SfxItemState aState = rItemSet.GetItemState( nWhichId );
124 if( aState == SfxItemState::SET )
125 {
126 sal_Int32 nFmt = static_cast< sal_Int32 >(
127 static_cast< const SfxUInt32Item & >(
128 rItemSet.Get( nWhichId )).GetValue());
129 aValue <<= nFmt;
130 }
131 else
132 return bChanged;
133 }
134
135 uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
136 if( bOverwriteAttributedDataPointsAlso )
137 {
138 rtl::Reference< DataSeries > xSeries( dynamic_cast<DataSeries*>(xPropertySet.get()) );
139 if( aValue != aOldValue ||
140 ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
141 {
143 bChanged = true;
144 }
145 }
146 else if( aOldValue != aValue )
147 {
148 xPropertySet->setPropertyValue(aPropertyName, aValue );
149 bChanged = true;
150 }
151 return bChanged;
152}
153
154bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso )
155{
156 bool bChanged = false;
157 if( !xPropertySet.is() )
158 return bChanged;
159 OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_SOURCE) ? OUString(CHART_UNONAME_NUMFMT) : OUString( "PercentageNumberFormat" );
160 sal_uInt16 nFormatWhich = (nWhichId==SID_ATTR_NUMBERFORMAT_SOURCE) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE;
161
162 if( rItemSet.GetItemState( nWhichId ) != SfxItemState::SET )
163 return bChanged;
164
165 uno::Any aNewValue;
166 bool bUseSourceFormat = static_cast< const SfxBoolItem & >(
167 rItemSet.Get( nWhichId )).GetValue();
168 xPropertySet->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(bUseSourceFormat));
169 if( !bUseSourceFormat )
170 {
171 SfxItemState aState = rItemSet.GetItemState( nFormatWhich );
172 if( aState == SfxItemState::SET )
173 {
174 sal_Int32 nFormatKey = static_cast< sal_Int32 >(
175 static_cast< const SfxUInt32Item & >(
176 rItemSet.Get( nFormatWhich )).GetValue());
177 aNewValue <<= nFormatKey;
178 }
179 else
180 return bChanged;
181 }
182
183 uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
184 if( bOverwriteAttributedDataPointsAlso )
185 {
186 rtl::Reference< DataSeries > xSeries( dynamic_cast<DataSeries*>(xPropertySet.get()) );
187 if( aNewValue != aOldValue ||
188 ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
189 {
191 bChanged = true;
192 }
193 }
194 else if( aOldValue != aNewValue )
195 {
196 xPropertySet->setPropertyValue( aPropertyName, aNewValue );
197 bChanged = true;
198 }
199
200 return bChanged;
201}
202
203} // anonymous namespace
204
206 const rtl::Reference<::chart::ChartModel> & xChartModel,
208 const uno::Reference< beans::XPropertySet > & rPropertySet,
209 const rtl::Reference< DataSeries > & xSeries,
210 SfxItemPool& rItemPool,
211 SdrModel& rDrawModel,
212 const uno::Reference<lang::XMultiServiceFactory>& xNamedPropertyContainerFactory,
213 GraphicObjectType eMapTo,
214 const awt::Size* pRefSize,
215 bool bDataSeries,
216 bool bUseSpecialFillColor,
217 sal_Int32 nSpecialFillColor,
218 bool bOverwriteLabelsForAttributedDataPointsAlso,
219 sal_Int32 nNumberFormat,
220 sal_Int32 nPercentNumberFormat,
221 sal_Int32 nPointIndex ) :
222 ItemConverter( rPropertySet, rItemPool ),
223 m_bDataSeries( bDataSeries ),
224 m_bOverwriteLabelsForAttributedDataPointsAlso(m_bDataSeries && bOverwriteLabelsForAttributedDataPointsAlso),
225 m_bUseSpecialFillColor(bUseSpecialFillColor),
226 m_nSpecialFillColor(ColorTransparency, nSpecialFillColor),
227 m_nNumberFormat(nNumberFormat),
228 m_nPercentNumberFormat(nPercentNumberFormat),
229 m_bForbidPercentValue(true),
230 m_bHideLegendEntry(false),
231 m_nPointIndex(nPointIndex),
232 m_xSeries(xSeries)
233{
235 rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, eMapTo ));
236 m_aConverters.emplace_back( new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize"));
237 if( bDataSeries )
238 {
239 assert(dynamic_cast<DataSeries*>(rPropertySet.get()));
240 m_aConverters.emplace_back( new StatisticsItemConverter( xChartModel, rPropertySet, rItemPool ));
241 m_aConverters.emplace_back( new SeriesOptionsItemConverter( xChartModel, xContext,
242 dynamic_cast<DataSeries*>(rPropertySet.get()), rItemPool ));
243 }
244
245 rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() );
246 rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) );
247 bool bFound = false;
248 bool bAmbiguous = false;
249 bool bSwapXAndY = xDiagram->getVertical( bFound, bAmbiguous );
251
252 m_bForbidPercentValue = ChartTypeHelper::getAxisType( xChartType, 0 ) != AxisType::CATEGORY;
253
254 if (bDataSeries)
255 return;
256
257 uno::Sequence<sal_Int32> deletedLegendEntriesSeq;
258 // "DeletedLegendEntries"
259 xSeries->getFastPropertyValue(PROP_DATASERIES_DELETED_LEGEND_ENTRIES) >>= deletedLegendEntriesSeq;
260 for (const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq))
261 {
262 if (nPointIndex == deletedLegendEntry)
263 {
264 m_bHideLegendEntry = true;
265 break;
266 }
267 }
268}
269
271{
272}
273
275{
276 for( const auto& pConv : m_aConverters )
277 pConv->FillItemSet( rOutItemSet );
278
279 // own items
280 ItemConverter::FillItemSet( rOutItemSet );
281
283 {
285 rOutItemSet.Put( XFillColorItem( OUString(), aColor ) );
286 }
287}
288
290{
291 bool bResult = false;
292
293 for( const auto& pConv : m_aConverters )
294 bResult = pConv->ApplyItemSet( rItemSet ) || bResult;
295
296 // own items
297 return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
298}
299
301{
302 // must span all used items!
303 if( m_bDataSeries )
304 return nRowWhichPairs;
306}
307
309{
310 ItemPropertyMapType & rMap( lcl_GetDataPointPropertyMap());
311 ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
312
313 if( aIt == rMap.end())
314 return false;
315
316 rOutProperty =(*aIt).second;
317 return true;
318}
319
321 sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
322{
323 bool bChanged = false;
324
325 switch( nWhichId )
326 {
332 {
333 const SfxBoolItem & rItem = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId ));
334
335 uno::Any aOldValue = GetPropertySet()->getPropertyValue(CHART_UNONAME_LABEL);
336 chart2::DataPointLabel aLabel;
337 if( aOldValue >>= aLabel )
338 {
339 sal_Bool& rValue = (nWhichId==SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : (
340 (nWhichId==SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : (
341 (nWhichId==SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : (
342 (nWhichId==SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME) ? aLabel.ShowSeriesName : aLabel.ShowLegendSymbol )));
343 bool bOldValue = rValue;
344 rValue = rItem.GetValue();
346 {
347 rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get()));
348 if( bOldValue != bool(rValue) ||
350 {
353 bChanged = true;
354 }
355 }
356 else if( bOldValue != bool(rValue) )
357 {
358 GetPropertySet()->setPropertyValue(CHART_UNONAME_LABEL , uno::Any(aLabel));
359 bChanged = true;
360 }
361 }
362 }
363 break;
364
365 case SID_ATTR_NUMBERFORMAT_VALUE:
366 case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: //fall through intended
367 {
368 bChanged = lcl_NumberFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
369 }
370 break;
371
372 case SID_ATTR_NUMBERFORMAT_SOURCE:
373 case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended
374 {
375 bChanged = lcl_UseSourceFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
376 }
377 break;
378
380 {
381 OUString aNewValue = static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue();
382 try
383 {
384 OUString aOldValue;
385 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aOldValue;
387 {
388 rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get()));
389 if( aOldValue != aNewValue ||
390 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelSeparator" , uno::Any( aOldValue ) ) )
391 {
392 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelSeparator" , uno::Any( aNewValue ) );
393 bChanged = true;
394 }
395 }
396 else if( aOldValue != aNewValue )
397 {
398 GetPropertySet()->setPropertyValue( "LabelSeparator" , uno::Any( aNewValue ));
399 bChanged = true;
400 }
401 }
402 catch( const uno::Exception& )
403 {
404 TOOLS_WARN_EXCEPTION("chart2", "" );
405 }
406 }
407 break;
408
410 {
411
412 try
413 {
414 bool bNew = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
415 bool bOld = false;
416 GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bOld;
418 {
419 rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get()));
420 if( bOld!=bNew ||
421 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "TextWordWrap", uno::Any( bOld ) ) )
422 {
424 bChanged = true;
425 }
426 }
427 else if( bOld!=bNew )
428 {
429 GetPropertySet()->setPropertyValue( "TextWordWrap", uno::Any( bNew ));
430 bChanged = true;
431 }
432 }
433 catch( const uno::Exception& )
434 {
435 TOOLS_WARN_EXCEPTION("chart2", "" );
436 }
437 }
438 break;
439
441 {
442
443 try
444 {
445 sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
446 sal_Int32 nOld = -1;
447 RelativePosition aCustomLabelPosition;
448 GetPropertySet()->getPropertyValue("LabelPlacement") >>= nOld;
450 {
451 rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get()));
452 if( nOld!=nNew ||
453 DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelPlacement" , uno::Any( nOld ) ) )
454 {
455 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelPlacement" , uno::Any( nNew ) );
456 bChanged = true;
457 }
458 }
459 else if( nOld!=nNew || (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition) )
460 {
461 GetPropertySet()->setPropertyValue("LabelPlacement", uno::Any(nNew));
462 GetPropertySet()->setPropertyValue("CustomLabelPosition", uno::Any());
463 bChanged = true;
464 }
465 }
466 catch( const uno::Exception& )
467 {
468 TOOLS_WARN_EXCEPTION("chart2", "" );
469 }
470 }
471 break;
472
474 {
475 sal_Int32 nStyle =
476 static_cast< const SfxInt32Item & >(
477 rItemSet.Get( nWhichId )).GetValue();
478 chart2::Symbol aSymbol;
479
480 GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
481 sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol );
482
483 if( nStyle != nOldStyle )
484 {
485 bool bDeleteSymbol = false;
486 switch( nStyle )
487 {
489 aSymbol.Style = chart2::SymbolStyle_NONE;
490 break;
492 aSymbol.Style = chart2::SymbolStyle_AUTO;
493 break;
495 aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
496 break;
498 bDeleteSymbol = true;
499 break;
500
501 default:
502 aSymbol.Style = chart2::SymbolStyle_STANDARD;
503 aSymbol.StandardSymbol = nStyle;
504 }
505
506 if( bDeleteSymbol )
507 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any());
508 else
509 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol ));
510 bChanged = true;
511 }
512 }
513 break;
514
516 {
517 Size aSize = static_cast< const SvxSizeItem & >(
518 rItemSet.Get( nWhichId )).GetSize();
519 chart2::Symbol aSymbol;
520
521 GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
522 if( aSize.getWidth() != aSymbol.Size.Width ||
523 aSize.getHeight() != aSymbol.Size.Height )
524 {
525 aSymbol.Size.Width = aSize.getWidth();
526 aSymbol.Size.Height = aSize.getHeight();
527
528 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol ));
529 bChanged = true;
530 }
531 }
532 break;
533
535 {
536 const SvxBrushItem & rBrshItem( static_cast< const SvxBrushItem & >(
537 rItemSet.Get( nWhichId )));
538 uno::Any aXGraphicAny;
539 const Graphic *pGraphic( rBrshItem.GetGraphic());
540 if( pGraphic )
541 {
543 if( xGraphic.is())
544 {
545 aXGraphicAny <<= xGraphic;
546 chart2::Symbol aSymbol;
547 GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol;
548 if( aSymbol.Graphic != xGraphic )
549 {
550 aSymbol.Graphic = xGraphic;
551 GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol ));
552 bChanged = true;
553 }
554 }
555 }
556 }
557 break;
558
560 {
561 double fValue = toDegrees(rItemSet.Get(SCHATTR_TEXT_DEGREES).GetValue());
562 double fOldValue = 0.0;
563 bool bPropExisted =
564 ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldValue );
565
566 if( ! bPropExisted || fOldValue != fValue )
567 {
568 GetPropertySet()->setPropertyValue( "TextRotation" , uno::Any( fValue ));
569 bChanged = true;
570 }
571 }
572 break;
573
575 {
576 bool bHideLegendEntry = static_cast<const SfxBoolItem &>(rItemSet.Get(nWhichId)).GetValue();
577 if (bHideLegendEntry != m_bHideLegendEntry)
578 {
579 uno::Sequence<sal_Int32> deletedLegendEntriesSeq;
580 // "DeletedLegendEntries"
581 m_xSeries->getFastPropertyValue(PROP_DATASERIES_DELETED_LEGEND_ENTRIES) >>= deletedLegendEntriesSeq;
582 std::vector<sal_Int32> deletedLegendEntries;
583 for (const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq))
584 {
585 if (bHideLegendEntry || m_nPointIndex != deletedLegendEntry)
586 deletedLegendEntries.push_back(deletedLegendEntry);
587 }
588 if (bHideLegendEntry)
589 deletedLegendEntries.push_back(m_nPointIndex);
590 // "DeletedLegendEntries"
592 }
593 }
594 break;
595
597 {
598 try
599 {
600 bool bNew = static_cast<const SfxBoolItem&>(rItemSet.Get(nWhichId)).GetValue();
601 bool bOld = true;
602 if( (m_xSeries->getPropertyValue("ShowCustomLeaderLines") >>= bOld) && bOld != bNew )
603 {
604 m_xSeries->setPropertyValue("ShowCustomLeaderLines", uno::Any(bNew));
605 bChanged = true;
606 }
607 }
608 catch (const uno::Exception&)
609 {
610 TOOLS_WARN_EXCEPTION("chart2", "");
611 }
612 }
613 break;
614 }
615
616 return bChanged;
617}
618
620 sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
621{
622 switch( nWhichId )
623 {
629 {
630 chart2::DataPointLabel aLabel;
632 {
633 bool bValue = (nWhichId==SCHATTR_DATADESCR_SHOW_NUMBER) ? aLabel.ShowNumber : (
634 (nWhichId==SCHATTR_DATADESCR_SHOW_PERCENTAGE) ? aLabel.ShowNumberInPercent : (
635 (nWhichId==SCHATTR_DATADESCR_SHOW_CATEGORY) ? aLabel.ShowCategoryName : (
636 (nWhichId==SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME) ? aLabel.ShowSeriesName : aLabel.ShowLegendSymbol )));
637
638 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
639
641 {
643 dynamic_cast<DataSeries*>(GetPropertySet().get()), CHART_UNONAME_LABEL , uno::Any(aLabel) ) )
644 {
645 rOutItemSet.InvalidateItem(nWhichId);
646 }
647 }
648 }
649 }
650 break;
651
652 case SID_ATTR_NUMBERFORMAT_VALUE:
653 {
654 sal_Int32 nKey = 0;
655 if (!(GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nKey))
656 nKey = m_nNumberFormat;
657 rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
658 }
659 break;
660
662 {
663 sal_Int32 nKey = 0;
664 if( !(GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ) >>= nKey) )
666 rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
667 }
668 break;
669
670 case SID_ATTR_NUMBERFORMAT_SOURCE:
671 {
672 bool bUseSourceFormat = false;
673 try
674 {
675 GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
676 }
677 catch (const uno::Exception&)
678 {
679 TOOLS_WARN_EXCEPTION("chart2", "");
680 }
681 bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue() && !bUseSourceFormat;
682 rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
683 }
684 break;
686 {
687 bool bUseSourceFormat = false;
688 try
689 {
690 GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
691 }
692 catch (const uno::Exception&)
693 {
694 TOOLS_WARN_EXCEPTION("chart2", "");
695 }
696 bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ).hasValue() && !bUseSourceFormat;
697 rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
698 }
699 break;
700
702 {
703 try
704 {
705 OUString aValue;
706 GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aValue;
707 rOutItemSet.Put( SfxStringItem( nWhichId, aValue ));
708 }
709 catch( const uno::Exception& )
710 {
711 TOOLS_WARN_EXCEPTION("chart2", "" );
712 }
713 }
714 break;
715
717 {
718 try
719 {
720 bool bValue = false;
721 GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bValue;
722 rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
723 }
724 catch( const uno::Exception& )
725 {
726 TOOLS_WARN_EXCEPTION("chart2", "" );
727 }
728 }
729 break;
730
732 {
733 try
734 {
735 sal_Int32 nPlacement=0;
736 RelativePosition aCustomLabelPosition;
737 if( !m_bOverwriteLabelsForAttributedDataPointsAlso && (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition) )
738 rOutItemSet.Put(SfxInt32Item(nWhichId, css::chart::DataLabelPlacement::CUSTOM));
739 else if( GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nPlacement )
740 rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement ));
741 else if( m_aAvailableLabelPlacements.hasElements() )
742 rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] ));
743 }
744 catch( const uno::Exception& )
745 {
746 TOOLS_WARN_EXCEPTION("chart2", "" );
747 }
748 }
749 break;
750
752 {
753 rOutItemSet.Put( SfxIntegerListItem( nWhichId, m_aAvailableLabelPlacements ) );
754 }
755 break;
756
758 {
759 rOutItemSet.Put( SfxBoolItem( nWhichId, m_bForbidPercentValue ));
760 }
761 break;
762
764 {
765 try
766 {
767 bool bValue = true;
768 if( m_xSeries->getPropertyValue( "ShowCustomLeaderLines" ) >>= bValue )
769 rOutItemSet.Put(SfxBoolItem(nWhichId, bValue));
770 }
771 catch (const uno::Exception&)
772 {
773 TOOLS_WARN_EXCEPTION("chart2", "");
774 }
775 }
776 break;
777
779 {
780 chart2::Symbol aSymbol;
781 if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
782 rOutItemSet.Put( SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) ));
783 }
784 break;
785
787 {
788 chart2::Symbol aSymbol;
789 if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
790 rOutItemSet.Put(
791 SvxSizeItem( nWhichId, Size( aSymbol.Size.Width, aSymbol.Size.Height ) ));
792 }
793 break;
794
796 {
797 chart2::Symbol aSymbol;
798 if(( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol )
799 && aSymbol.Graphic.is() )
800 {
801 rOutItemSet.Put( SvxBrushItem( Graphic( aSymbol.Graphic ), GPOS_MM, SCHATTR_SYMBOL_BRUSH ));
802 }
803 }
804 break;
805
807 {
808 double fValue = 0;
809
810 if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fValue )
811 {
812 rOutItemSet.Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, Degree100(static_cast< sal_Int32 >(
813 ::rtl::math::round( fValue * 100.0 ) ) )));
814 }
815 }
816 break;
817
819 {
820 rOutItemSet.Put(SfxBoolItem(nWhichId, m_bHideLegendEntry));
821 break;
822 }
823 break;
824 }
825}
826
827}
828
829/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_SHOW_SYMBOL(SCHATTR_DATADESCR_START+3)
constexpr TypedWhichId< SvxSizeItem > SCHATTR_SYMBOL_SIZE(SCHATTR_AXIS_END+4)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_DATADESCR_PLACEMENT(SCHATTR_DATADESCR_START+6)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_CUSTOM_LEADER_LINES(SCHATTR_DATADESCR_START+9)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME(SCHATTR_DATADESCR_START+12)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_PERCENT_NUMBERFORMAT_SOURCE(SCHATTR_DATADESCR_START+11)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_STYLE_SYMBOL(SCHATTR_STYLE_START+8)
constexpr TypedWhichId< SfxStringItem > SCHATTR_DATADESCR_SEPARATOR(SCHATTR_DATADESCR_START+5)
constexpr TypedWhichId< SfxUInt32Item > SCHATTR_PERCENT_NUMBERFORMAT_VALUE(SCHATTR_DATADESCR_START+10)
constexpr TypedWhichId< SfxIntegerListItem > SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS(SCHATTR_DATADESCR_START+7)
constexpr TypedWhichId< SdrAngleItem > SCHATTR_TEXT_DEGREES(SCHATTR_TEXT_START)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_NO_PERCENTVALUE(SCHATTR_DATADESCR_START+8)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY(SCHATTR_AXIS_END+5)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_SHOW_NUMBER(SCHATTR_DATADESCR_START)
constexpr TypedWhichId< SvxBrushItem > SCHATTR_SYMBOL_BRUSH(SCHATTR_AXIS_END+1)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_WRAP_TEXT(SCHATTR_DATADESCR_START+4)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_SHOW_PERCENTAGE(SCHATTR_DATADESCR_START+1)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_STYLE_SHAPE(SCHATTR_STYLE_START+9)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_DATADESCR_SHOW_CATEGORY(SCHATTR_DATADESCR_START+2)
rtl::Reference< ::chart::DataSeries > m_xSeries
const WhichRangesContainer nRowWhichPairs(svl::Items< SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, SCHATTR_STYLE_START, SCHATTR_STYLE_END, SCHATTR_AXIS, SCHATTR_AXIS, SCHATTR_SYMBOL_BRUSH, SCHATTR_SYMBOL_BRUSH, SCHATTR_SYMBOL_SIZE, SCHATTR_SYMBOL_SIZE, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_BAR_OVERLAP, SCHATTR_BAR_CONNECT, SCHATTR_GROUP_BARS_PER_AXIS, SCHATTR_AXIS_FOR_ALL_SERIES, XATTR_LINE_FIRST, XATTR_LINE_LAST, XATTR_FILL_FIRST, XATTR_FILL_LAST, SDRATTR_3D_FIRST, SDRATTR_3D_LAST, EE_ITEMS_START, EE_ITEMS_END, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING >)
const WhichRangesContainer nDataPointWhichPairs(svl::Items< SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, SCHATTR_STYLE_START, SCHATTR_STYLE_END, SCHATTR_SYMBOL_BRUSH, SCHATTR_SYMBOL_BRUSH, SCHATTR_SYMBOL_SIZE, SCHATTR_SYMBOL_SIZE, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, XATTR_LINE_FIRST, XATTR_LINE_LAST, XATTR_FILL_FIRST, XATTR_FILL_LAST, SDRATTR_3D_FIRST, SDRATTR_3D_LAST, EE_ITEMS_START, EE_ITEMS_END, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING >)
GPOS_MM
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
bool GetValue() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void InvalidateItem(sal_uInt16 nWhich)
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
const Graphic * GetGraphic(OUString const &referer=OUString()) const
static css::uno::Sequence< sal_Int32 > getSupportedLabelPlacements(const rtl::Reference< ::chart::ChartType > &xChartType, bool bSwapXAndY, const rtl::Reference< ::chart::DataSeries > &xSeries)
static sal_Int32 getAxisType(const rtl::Reference< ::chart::ChartType > &xChartType, sal_Int32 nDimensionIndex)
virtual bool ApplySpecialItem(sal_uInt16 nWhichId, const SfxItemSet &rItemSet) override
for items that can not be mapped directly to a property.
virtual void FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet &rOutItemSet) const override
for items that can not be mapped directly to a property.
virtual bool GetItemProperty(tWhichIdType nWhichId, tPropertyNameWithMemberId &rOutProperty) const override
implement this method to return a Property object for a given which id.
virtual bool ApplyItemSet(const SfxItemSet &rItemSet) override
applies all properties that are results of a conversion from all items in rItemSet to the internal XP...
virtual void FillItemSet(SfxItemSet &rOutItemSet) const override
applies all properties that can be mapped to items into the given item set.
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
rtl::Reference<::chart::DataSeries > m_xSeries
std::vector< std::unique_ptr< ItemConverter > > m_aConverters
DataPointItemConverter(const rtl::Reference<::chart::ChartModel > &xChartModel, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::beans::XPropertySet > &rPropertySet, const rtl::Reference<::chart::DataSeries > &xSeries, SfxItemPool &rItemPool, SdrModel &rDrawModel, const css::uno::Reference< css::lang::XMultiServiceFactory > &xNamedPropertyContainerFactory, GraphicObjectType eMapTo, const css::awt::Size *pRefSize=nullptr, bool bDataSeries=false, bool bUseSpecialFillColor=false, sal_Int32 nSpecialFillColor=0, bool bOverwriteLabelsForAttributedDataPointsAlso=false, sal_Int32 nNumberFormat=0, sal_Int32 nPercentNumberFormat=0, sal_Int32 nPointIndex=-1)
css::uno::Sequence< sal_Int32 > m_aAvailableLabelPlacements
This class serves for conversion between properties of an XPropertySet and SfxItems in SfxItemSets.
virtual void FillItemSet(SfxItemSet &rOutItemSet) const
applies all properties that can be mapped to items into the given item set.
std::pair< tPropertyNameType, tMemberIdType > tPropertyNameWithMemberId
const css::uno::Reference< css::beans::XPropertySet > & GetPropertySet() const
Returns the XPropertySet that was given in the CTOR and is used to apply items in ApplyItemSet().
virtual bool ApplyItemSet(const SfxItemSet &rItemSet)
applies all properties that are results of a conversion from all items in rItemSet to the internal XP...
ColorTransparency
double toDegrees(D x)
#define TOOLS_WARN_EXCEPTION(area, stream)
OOO_DLLPUBLIC_CHARTTOOLS void setPropertyAlsoToAllAttributedDataPoints(const rtl::Reference< ::chart::DataSeries > &xSeries, const OUString &rPropertyName, const css::uno::Any &rPropertyValue)
OOO_DLLPUBLIC_CHARTTOOLS bool hasAttributedDataPointDifferentValue(const rtl::Reference< ::chart::DataSeries > &xSeries, const OUString &rPropertyName, const css::uno::Any &rPropertyValue)
std::map< ItemConverter::tWhichIdType, std::pair< ItemConverter::tPropertyNameType, ItemConverter::tMemberIdType > > ItemPropertyMapType
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
const char GetValue[]
SfxItemState
#define SVX_SYMBOLTYPE_BRUSHITEM
#define SVX_SYMBOLTYPE_NONE
#define SVX_SYMBOLTYPE_UNKNOWN
#define SVX_SYMBOLTYPE_AUTO
unsigned char sal_Bool
OUString aLabel
constexpr OUStringLiteral CHART_UNONAME_LINK_TO_SRC_NUMFMT
Definition: unonames.hxx:21
constexpr OUStringLiteral CHART_UNONAME_NUMFMT
Definition: unonames.hxx:20
constexpr OUStringLiteral CHART_UNONAME_CUSTOM_LABEL_FIELDS
Definition: unonames.hxx:36
constexpr OUStringLiteral CHART_UNONAME_LABEL
Definition: unonames.hxx:24