LibreOffice Module chart2 (master) 1
DataSeriesPointWrapper.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
22#include <ChartType.hxx>
23#include <ChartTypeHelper.hxx>
24#include <DiagramHelper.hxx>
25#include <DataSeries.hxx>
28#include <FillProperties.hxx>
32#include <WrappedProperty.hxx>
41#include <unonames.hxx>
42
43#include <o3tl/safeint.hxx>
44#include <rtl/math.hxx>
45
46#include <algorithm>
48#include <com/sun/star/beans/PropertyAttribute.hpp>
49#include <com/sun/star/chart/ChartAxisAssign.hpp>
50#include <com/sun/star/chart/ChartErrorCategory.hpp>
51#include <com/sun/star/chart/ChartSymbolType.hpp>
52#include <com/sun/star/chart2/XDataSeries.hpp>
53#include <com/sun/star/drawing/LineJoint.hpp>
54#include <com/sun/star/drawing/LineStyle.hpp>
55#include <com/sun/star/drawing/FillStyle.hpp>
56#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
60
61using namespace ::com::sun::star;
62using namespace ::chart::wrapper;
63using namespace ::chart::DataSeriesProperties;
64
65using ::com::sun::star::uno::Reference;
66using ::com::sun::star::uno::Sequence;
67using ::com::sun::star::beans::Property;
68using ::com::sun::star::uno::Any;
69
70namespace
71{
72
73enum
74{
75 //data point properties
76 PROP_SERIES_DATAPOINT_SOLIDTYPE,
77 PROP_SERIES_DATAPOINT_SEGMENT_OFFSET,
78 PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL,
79 PROP_SERIES_DATAPOINT_LABEL_SEPARATOR,
80 PROP_SERIES_NUMBERFORMAT,
81 PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE,
82 PROP_SERIES_PERCENTAGE_NUMBERFORMAT,
83 PROP_SERIES_DATAPOINT_TEXT_WORD_WRAP,
84 PROP_SERIES_DATAPOINT_LABEL_PLACEMENT,
85 //other series properties
86 PROP_SERIES_ATTACHED_AXIS,
87 PROP_SERIES_SHOW_CUSTOM_LEADERLINES,
88 PROP_SERIES_DATAPOINT_TEXT_ROTATION,
89 PROP_SERIES_DATAPOINT_LABEL_BORDER_STYLE,
90 PROP_SERIES_DATAPOINT_LABEL_BORDER_WIDTH,
91 PROP_SERIES_DATAPOINT_LABEL_BORDER_COLOR,
92 PROP_SERIES_DATAPOINT_LABEL_BORDER_TRANS,
93 PROP_SERIES_DATAPOINT_LABEL_FILL_STYLE,
94 PROP_SERIES_DATAPOINT_LABEL_FILL_COLOR,
95 PROP_SERIES_DATAPOINT_LABEL_FILL_BACKGROUND,
96 PROP_SERIES_DATAPOINT_LABEL_FILL_HATCH_NAME
97};
98
99void lcl_AddPropertiesToVector_PointProperties(
100 std::vector< Property > & rOutProperties )
101{
102 //service chart::Chart3DBarProperties
103 rOutProperties.emplace_back( "SolidType",
104 PROP_SERIES_DATAPOINT_SOLIDTYPE,
106 beans::PropertyAttribute::BOUND
107 | beans::PropertyAttribute::MAYBEDEFAULT );
108
109 rOutProperties.emplace_back( "SegmentOffset",
110 PROP_SERIES_DATAPOINT_SEGMENT_OFFSET,
112 beans::PropertyAttribute::BOUND
113 | beans::PropertyAttribute::MAYBEDEFAULT );
114
115 rOutProperties.emplace_back( "D3DPercentDiagonal",
116 PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL,
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::MAYBEVOID );
120
121 rOutProperties.emplace_back( "LabelSeparator",
122 PROP_SERIES_DATAPOINT_LABEL_SEPARATOR,
124 beans::PropertyAttribute::BOUND
125 | beans::PropertyAttribute::MAYBEDEFAULT );
126
127 rOutProperties.emplace_back( CHART_UNONAME_NUMFMT,
128 PROP_SERIES_NUMBERFORMAT,
130 beans::PropertyAttribute::BOUND
131 | beans::PropertyAttribute::MAYBEVOID );
132
133 rOutProperties.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
134 PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE,
136 beans::PropertyAttribute::BOUND
137 | beans::PropertyAttribute::MAYBEDEFAULT );
138
139 rOutProperties.emplace_back( "PercentageNumberFormat",
140 PROP_SERIES_PERCENTAGE_NUMBERFORMAT,
142 beans::PropertyAttribute::BOUND
143 | beans::PropertyAttribute::MAYBEVOID );
144
145 rOutProperties.emplace_back( "TextWordWrap",
146 PROP_SERIES_DATAPOINT_TEXT_WORD_WRAP,
148 beans::PropertyAttribute::BOUND
149 | beans::PropertyAttribute::MAYBEVOID );
150
151 rOutProperties.emplace_back( "LabelPlacement",
152 PROP_SERIES_DATAPOINT_LABEL_PLACEMENT,
154 beans::PropertyAttribute::BOUND
155 | beans::PropertyAttribute::MAYBEVOID );
156
157 rOutProperties.emplace_back( "TextRotation",
158 PROP_SERIES_DATAPOINT_TEXT_ROTATION,
160 beans::PropertyAttribute::BOUND
161 | beans::PropertyAttribute::MAYBEDEFAULT );
162
163 rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_STYLE,
164 PROP_SERIES_DATAPOINT_LABEL_BORDER_STYLE,
166 beans::PropertyAttribute::BOUND
167 | beans::PropertyAttribute::MAYBEDEFAULT );
168
169 rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_STYLE,
170 PROP_SERIES_DATAPOINT_LABEL_FILL_STYLE,
172 beans::PropertyAttribute::BOUND
173 | beans::PropertyAttribute::MAYBEDEFAULT );
174
175 rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_COLOR,
176 PROP_SERIES_DATAPOINT_LABEL_FILL_COLOR,
178 beans::PropertyAttribute::BOUND
179 | beans::PropertyAttribute::MAYBEVOID
180 | beans::PropertyAttribute::MAYBEDEFAULT );
181
182 rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_BACKGROUND,
183 PROP_SERIES_DATAPOINT_LABEL_FILL_BACKGROUND,
185 beans::PropertyAttribute::BOUND
186 | beans::PropertyAttribute::MAYBEDEFAULT );
187 rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_HATCH_NAME,
188 PROP_SERIES_DATAPOINT_LABEL_FILL_HATCH_NAME,
190 beans::PropertyAttribute::BOUND
191 | beans::PropertyAttribute::MAYBEDEFAULT );
192 rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_WIDTH,
193 PROP_SERIES_DATAPOINT_LABEL_BORDER_WIDTH,
195 beans::PropertyAttribute::BOUND
196 | beans::PropertyAttribute::MAYBEDEFAULT );
197
198 rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_COLOR,
199 PROP_SERIES_DATAPOINT_LABEL_BORDER_COLOR,
201 beans::PropertyAttribute::BOUND
202 | beans::PropertyAttribute::MAYBEVOID // "maybe auto"
203 | beans::PropertyAttribute::MAYBEDEFAULT );
204
205 rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_TRANS,
206 PROP_SERIES_DATAPOINT_LABEL_BORDER_TRANS,
208 beans::PropertyAttribute::BOUND
209 | beans::PropertyAttribute::MAYBEDEFAULT );
210}
211
212void lcl_AddPropertiesToVector_SeriesOnly(
213 std::vector< Property > & rOutProperties )
214{
215 rOutProperties.emplace_back( "Axis",
216 PROP_SERIES_ATTACHED_AXIS,
218 beans::PropertyAttribute::BOUND
219 | beans::PropertyAttribute::MAYBEDEFAULT );
220
221 rOutProperties.emplace_back( "ShowCustomLeaderLines",
222 PROP_SERIES_SHOW_CUSTOM_LEADERLINES,
224 beans::PropertyAttribute::BOUND
225 | beans::PropertyAttribute::MAYBEDEFAULT );
226}
227
228uno::Sequence< Property > lcl_GetPropertySequence( DataSeriesPointWrapper::eType _eType )
229{
230 std::vector< css::beans::Property > aProperties;
231
232 lcl_AddPropertiesToVector_PointProperties( aProperties );
234 {
235 lcl_AddPropertiesToVector_SeriesOnly( aProperties );
236 WrappedStatisticProperties::addProperties( aProperties );
237 }
238 WrappedSymbolProperties::addProperties( aProperties ); //for series and points
239 WrappedDataCaptionProperties::addProperties( aProperties ); //for series and points
240
246
247 std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() );
248
249 return comphelper::containerToSequence( aProperties );
250}
251
252const Sequence< Property >& StaticSeriesWrapperPropertyArray()
253{
254 static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES ) );
255 return aPropSeq;
256};
257
258const Sequence< Property >& StaticPointWrapperPropertyArray()
259{
260 static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT ) );
261 return aPropSeq;
262};
263
264//PROP_SERIES_ATTACHED_AXIS
265class WrappedAttachedAxisProperty : public ::chart::WrappedProperty
266{
267public:
268 explicit WrappedAttachedAxisProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
269
270 virtual void setPropertyValue( const Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
271
272 virtual Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
273
274 virtual Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
275
276protected:
277 std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
278};
279
280WrappedAttachedAxisProperty::WrappedAttachedAxisProperty(
281 const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact )
282 : WrappedProperty("Axis",OUString())
283 , m_spChart2ModelContact( spChart2ModelContact )
284{
285}
286
287Any WrappedAttachedAxisProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
288{
289 Any aRet;
290 aRet <<= css::chart::ChartAxisAssign::PRIMARY_Y;
291 return aRet;
292}
293
294Any WrappedAttachedAxisProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
295{
296 Any aRet;
297
298 rtl::Reference< ::chart::DataSeries > xDataSeries( dynamic_cast<::chart::DataSeries*>(xInnerPropertySet.get()) );
299 bool bAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries );
300 if( bAttachedToMainAxis )
301 aRet <<= css::chart::ChartAxisAssign::PRIMARY_Y;
302 else
303 aRet <<= css::chart::ChartAxisAssign::SECONDARY_Y;
304 return aRet;
305}
306
307void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
308{
309 rtl::Reference< ::chart::DataSeries > xDataSeries( dynamic_cast<::chart::DataSeries*>(xInnerPropertySet.get()) );
310
311 sal_Int32 nChartAxisAssign = css::chart::ChartAxisAssign::PRIMARY_Y;
312 if( ! (rOuterValue >>= nChartAxisAssign) )
313 throw lang::IllegalArgumentException("Property Axis requires value of type sal_Int32", nullptr, 0 );
314
315 bool bNewAttachedToMainAxis = nChartAxisAssign == css::chart::ChartAxisAssign::PRIMARY_Y;
316 bool bOldAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries );
317
318 if( bNewAttachedToMainAxis != bOldAttachedToMainAxis)
319 {
321 if( xDiagram.is() )
322 xDiagram->attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, m_spChart2ModelContact->m_xContext, false );
323 }
324}
325
326class WrappedSegmentOffsetProperty : public ::chart::WrappedProperty
327{
328public:
329 WrappedSegmentOffsetProperty();
330
331protected:
332 virtual Any convertInnerToOuterValue( const Any& rInnerValue ) const override;
333 virtual Any convertOuterToInnerValue( const Any& rOuterValue ) const override;
334};
335
336WrappedSegmentOffsetProperty::WrappedSegmentOffsetProperty() :
337 WrappedProperty("SegmentOffset","Offset")
338{}
339
340Any WrappedSegmentOffsetProperty::convertInnerToOuterValue( const Any& rInnerValue ) const
341{
342 // convert new double offset to former integer segment-offset
343 double fOffset = 0;
344 Any aResult( rInnerValue );
345
346 if( rInnerValue >>= fOffset )
347 aResult <<= static_cast< sal_Int32 >( ::rtl::math::round( fOffset * 100.0 ));
348
349 return aResult;
350}
351
352Any WrappedSegmentOffsetProperty::convertOuterToInnerValue( const Any& rOuterValue ) const
353{
354 // convert former integer segment-offset to new double offset
355 sal_Int32 nOffset = 0;
356 Any aResult( rOuterValue );
357
358 if( rOuterValue >>= nOffset )
359 aResult <<= static_cast< double >( nOffset ) / 100.0;
360
361 return aResult;
362}
363
364class WrappedLineColorProperty : public WrappedSeriesAreaOrLineProperty
365{
366public:
367 explicit WrappedLineColorProperty( DataSeriesPointWrapper* pDataSeriesPointWrapper );
368
369 virtual void setPropertyValue( const Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
370
371 virtual void setPropertyToDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
372
373 virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
374
375protected:
376 DataSeriesPointWrapper* m_pDataSeriesPointWrapper;
377 mutable Any m_aDefaultValue;
378};
379
380WrappedLineColorProperty::WrappedLineColorProperty(
381 DataSeriesPointWrapper* pDataSeriesPointWrapper )
382 : WrappedSeriesAreaOrLineProperty("LineColor","BorderColor","Color", pDataSeriesPointWrapper )
383 , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper )
384 , m_aDefaultValue(uno::Any(sal_Int32( 0x0099ccff ))) // blue 8
385{
386}
387
388void WrappedLineColorProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
389{
390 if( !m_pDataSeriesPointWrapper || !m_pDataSeriesPointWrapper->isLinesForbidden() )
391 WrappedSeriesAreaOrLineProperty::setPropertyValue( rOuterValue, xInnerPropertySet );
392}
393
394void WrappedLineColorProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
395{
396 if( !m_pDataSeriesPointWrapper || !m_pDataSeriesPointWrapper->isLinesForbidden() )
397 WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState );
398}
399
400Any WrappedLineColorProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
401{
402 if( m_pDataSeriesPointWrapper && !m_pDataSeriesPointWrapper->isSupportingAreaProperties() )
403 return m_aDefaultValue;
404 else
405 return WrappedSeriesAreaOrLineProperty::getPropertyDefault( xInnerPropertyState );
406}
407
408class WrappedLineStyleProperty : public WrappedSeriesAreaOrLineProperty
409{
410public:
411 explicit WrappedLineStyleProperty( DataSeriesPointWrapper* pDataSeriesPointWrapper );
412
413 virtual void setPropertyValue( const Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
414
415 virtual void setPropertyToDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
416
417protected:
418 DataSeriesPointWrapper* m_pDataSeriesPointWrapper;
419};
420
421WrappedLineStyleProperty::WrappedLineStyleProperty(
422 DataSeriesPointWrapper* pDataSeriesPointWrapper )
423 : WrappedSeriesAreaOrLineProperty("LineStyle","BorderStyle", "LineStyle", pDataSeriesPointWrapper )
424 , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper )
425{
426}
427
428void WrappedLineStyleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
429{
430 Any aNewValue(rOuterValue);
431 if( m_pDataSeriesPointWrapper && m_pDataSeriesPointWrapper->isLinesForbidden() )
432 {
433 aNewValue <<= drawing::LineStyle_NONE;
434 }
435 WrappedSeriesAreaOrLineProperty::setPropertyValue( aNewValue, xInnerPropertySet );
436}
437
438void WrappedLineStyleProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
439{
440 if( !m_pDataSeriesPointWrapper || !m_pDataSeriesPointWrapper->isLinesForbidden() )
441 WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState );
442}
443
444} // anonymous namespace
445
446namespace chart::wrapper
447{
448
449DataSeriesPointWrapper::DataSeriesPointWrapper( std::shared_ptr<Chart2ModelContact> spChart2ModelContact)
450 : m_spChart2ModelContact( std::move(spChart2ModelContact) )
452 , m_nSeriesIndexInNewAPI( -1 )
453 , m_nPointIndex( -1 )
454 , m_bLinesAllowed(true)
455{
456 //need initialize call afterwards
457}
458
460{
461 OSL_PRECOND(aArguments.hasElements(),"need at least 1 argument to initialize the DataSeriesPointWrapper: series reference + optional datapoint index");
462
463 m_nSeriesIndexInNewAPI = -1;//ignored in this case
464 m_nPointIndex = -1;
465 if( aArguments.hasElements() )
466 {
468 aArguments[0] >>= xTmp;
469 auto p = dynamic_cast<DataSeries*>(xTmp.get());
470 assert(p);
472 if( aArguments.getLength() >= 2 )
474 }
475
476 if( !m_xDataSeries.is() )
477 throw uno::Exception(
478 "DataSeries index invalid", static_cast< ::cppu::OWeakObject * >( this ));
479
480 //todo: check upper border of point index
481
482 if( m_nPointIndex >= 0 )
484 else
486}
487
489 sal_Int32 nSeriesIndexInNewAPI ,
490 sal_Int32 nPointIndex, //ignored for series
491 std::shared_ptr<Chart2ModelContact> spChart2ModelContact)
492 : m_spChart2ModelContact( std::move(spChart2ModelContact) )
493 , m_eType( _eType )
494 , m_nSeriesIndexInNewAPI( nSeriesIndexInNewAPI )
495 , m_nPointIndex( (_eType == DATA_POINT) ? nPointIndex : -1 )
496 , m_bLinesAllowed( false )
497{
498}
499
501{
502}
503
504// ____ XComponent ____
506{
507 std::unique_lock g(m_aMutex);
508 uno::Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
509 m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) );
510
511 m_xDataSeries.clear();
512 clearWrappedPropertySet();
513}
514
517{
518 std::unique_lock g(m_aMutex);
520}
521
524{
525 std::unique_lock g(m_aMutex);
527}
528
529// ____ XEventListener ____
530void SAL_CALL DataSeriesPointWrapper::disposing( const lang::EventObject& /*Source*/ )
531{
532}
533
535{
538 rtl::Reference< ::chart::ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) );
539 sal_Int32 nDimensionCount = xDiagram->getDimension();
540
541 return ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount );
542}
543
545{
547 if( !xSeries.is() )
548 {
550 std::vector< rtl::Reference< DataSeries > > aSeriesList =
551 xDiagram->getDataSeries();
552
553 if( m_nSeriesIndexInNewAPI >= 0 && o3tl::make_unsigned(m_nSeriesIndexInNewAPI) < aSeriesList.size() )
554 xSeries = aSeriesList[m_nSeriesIndexInNewAPI];
555 }
556
557 return xSeries;
558}
559
561{
563
565
566 // may throw an IllegalArgumentException
567 if( xSeries.is() )
568 xPointProp = xSeries->getDataPointByIndex( m_nPointIndex );
569
570 return xPointProp;
571}
572
573//ReferenceSizePropertyProvider
575{
577 if( xProp.is() )
578 {
579 if( xProp->getPropertyValue("ReferencePageSize").hasValue() )
580 xProp->setPropertyValue("ReferencePageSize", uno::Any(
581 m_spChart2ModelContact->GetPageSize() ));
582 }
583}
585{
586 Any aRet;
588 if( xProp.is() )
589 aRet = xProp->getPropertyValue("ReferencePageSize");
590 return aRet;
591}
593{
594 return m_spChart2ModelContact->GetPageSize();
595}
596
597// WrappedPropertySet
598
599//XPropertyState
600beans::PropertyState SAL_CALL DataSeriesPointWrapper::getPropertyState( const OUString& rPropertyName )
601{
602 beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE );
603 try
604 {
605 if (rPropertyName == "SymbolBitmap" || rPropertyName == "SymbolBitmapURL")
606 {
608 sal_Int32 nVal = css::chart::ChartSymbolType::NONE;
609 if (aAny >>= nVal)
610 {
611 if (nVal != css::chart::ChartSymbolType::BITMAPURL)
612 return beans::PropertyState::PropertyState_DEFAULT_VALUE;
613 }
614 }
615
616 if( m_eType == DATA_SERIES )
617 aState = WrappedPropertySet::getPropertyState( rPropertyName );
618 else
619 {
620 if( rPropertyName == "FillColor")
621 {
623 bool bVaryColorsByPoint = false;
624 // "VaryColorsByPoint"
625 if( xSeries.is() && (xSeries->getFastPropertyValue(PROP_DATASERIES_VARY_COLORS_BY_POINT) >>= bVaryColorsByPoint)
626 && bVaryColorsByPoint )
627 return beans::PropertyState_DIRECT_VALUE;
628 }
629 else if( rPropertyName == "Lines"
630 || rPropertyName == "SymbolType"
631 || rPropertyName == "SymbolSize" )
632 return WrappedPropertySet::getPropertyState( rPropertyName );
633
634 uno::Any aDefault( getPropertyDefault( rPropertyName ) );
635 uno::Any aValue( getPropertyValue( rPropertyName ) );
636 if( aDefault==aValue )
637 aState = beans::PropertyState_DEFAULT_VALUE;
638 }
639 }
640 catch( const beans::UnknownPropertyException& )
641 {
642 throw;
643 }
644 catch( const uno::RuntimeException& )
645 {
646 throw;
647 }
648 catch( const lang::WrappedTargetException& e )
649 {
650 css::uno::Any a(e.TargetException);
651 throw css::lang::WrappedTargetRuntimeException(
652 "wrapped Exception " + e.Message,
653 css::uno::Reference<css::uno::XInterface>(), a);
654 }
655 catch( const uno::Exception& e )
656 {
657 css::uno::Any a(cppu::getCaughtException());
658 throw css::lang::WrappedTargetRuntimeException(
659 "wrapped Exception " + e.Message,
660 css::uno::Reference<css::uno::XInterface>(), a);
661 }
662 return aState;
663}
664
665void SAL_CALL DataSeriesPointWrapper::setPropertyToDefault( const OUString& rPropertyName )
666{
667 if( m_eType == DATA_SERIES )
669 else
670 {
671 //for data points the default is given by the series
672 setPropertyValue( rPropertyName, getPropertyDefault( rPropertyName ) );
673 }
674}
675Any SAL_CALL DataSeriesPointWrapper::getPropertyDefault( const OUString& rPropertyName )
676{
677 Any aRet;
678 try
679 {
680 sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
681 if( nHandle > 0 )
682 {
683 //always take the series current value as default for points
684 rtl::Reference< DataSeries > xInnerPropertySet = getDataSeries();
685 if( xInnerPropertySet.is() )
686 {
687 const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
688 if( pWrappedProperty )
689 aRet = pWrappedProperty->getPropertyValue(xInnerPropertySet);
690 else
691 aRet = xInnerPropertySet->getPropertyValue( rPropertyName );
692 }
693 }
694 }
695 catch( const beans::UnknownPropertyException& )
696 {
697 aRet = WrappedPropertySet::getPropertyDefault( rPropertyName );
698 }
699 return aRet;
700}
701
703{
704 if( m_eType == DATA_SERIES )
705 return getDataSeries();
706 return getDataPointProperties();
707}
708
710{
711 if( m_eType == DATA_SERIES )
712 return StaticSeriesWrapperPropertyArray();
713 else
714 return StaticPointWrapperPropertyArray();
715}
716
717std::vector< std::unique_ptr<WrappedProperty> > DataSeriesPointWrapper::createWrappedProperties()
718{
719 std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
720
722
723 if( m_eType == DATA_SERIES )
724 {
726 aWrappedProperties.emplace_back( new WrappedAttachedAxisProperty( m_spChart2ModelContact ) );
727
728 aWrappedProperties.emplace_back( new WrappedNumberFormatProperty(m_spChart2ModelContact) );
729 aWrappedProperties.emplace_back( new WrappedLinkNumberFormatProperty );
730 }
731
735
736 //add unnamed line properties (different inner names here)
737
738 aWrappedProperties.emplace_back( new WrappedProperty("FillColor","Color") );
739 aWrappedProperties.emplace_back( new WrappedLineStyleProperty( this ) );
740 aWrappedProperties.emplace_back( new WrappedLineColorProperty( this ) );
741 aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineDashName","BorderDashName","LineDashName", this ) );
742 aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineTransparence","BorderTransparency","Transparency", this ) );
743 aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineWidth","BorderWidth","LineWidth", this ) );
744 aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineCap","LineCap","LineCap", this ) );
745 aWrappedProperties.emplace_back( new WrappedProperty("FillStyle","FillStyle" ) );
746 aWrappedProperties.emplace_back( new WrappedProperty("FillTransparence","Transparency") );
747
748 aWrappedProperties.emplace_back( new WrappedIgnoreProperty("LineJoint", uno::Any( drawing::LineJoint_ROUND ) ) );
749 aWrappedProperties.emplace_back( new WrappedProperty("FillTransparenceGradientName","TransparencyGradientName") );
750 aWrappedProperties.emplace_back( new WrappedProperty("FillGradientName","GradientName") );
751 aWrappedProperties.emplace_back( new WrappedProperty("FillGradientStepCount","GradientStepCount") );
752 aWrappedProperties.emplace_back( new WrappedProperty("FillHatchName","HatchName") );
753 aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapName","FillBitmapName") );
754 aWrappedProperties.emplace_back( new WrappedProperty("FillBackground","FillBackground") );
755
756 //bitmap properties
757 aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapMode","FillBitmapMode") );
758 aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapSizeX","FillBitmapSizeX") );
759 aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapSizeY","FillBitmapSizeY") );
760 aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapLogicalSize","FillBitmapLogicalSize") );
761 aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapOffsetX","FillBitmapOffsetX") );
762 aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapOffsetY","FillBitmapOffsetY") );
763 aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapRectanglePoint","FillBitmapRectanglePoint") );
764 aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapPositionOffsetX","FillBitmapPositionOffsetX") );
765 aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapPositionOffsetY","FillBitmapPositionOffsetY") );
766
767 aWrappedProperties.emplace_back( new WrappedProperty("SolidType","Geometry3D") );
768 aWrappedProperties.emplace_back( new WrappedSegmentOffsetProperty() );
769 aWrappedProperties.emplace_back( new WrappedProperty("D3DPercentDiagonal","PercentDiagonal") );
770
771 aWrappedProperties.emplace_back( new WrappedTextRotationProperty() );
772
773 return aWrappedProperties;
774}
775
776void SAL_CALL DataSeriesPointWrapper::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
777{
778 if(rPropertyName == "Lines")
779 {
780 if( ! (rValue >>= m_bLinesAllowed) )
781 throw lang::IllegalArgumentException("Property Lines requires value of type sal_Bool", nullptr, 0 );
782 }
783
784 sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
785 static const sal_Int32 nErrorCategoryHandle = getInfoHelper().getHandleByName("ErrorCategory");
786 if( nErrorCategoryHandle == nHandle )
787 {
788 css::chart::ChartErrorCategory aNewValue = css::chart::ChartErrorCategory_NONE;
789 rValue >>= aNewValue;
790 Any aLow, aHigh;
791 bool bSetHighAndLowValues = false;
792 switch(aNewValue)
793 {
794 case css::chart::ChartErrorCategory_CONSTANT_VALUE:
795 aHigh = getPropertyValue("ConstantErrorHigh");
796 aLow = getPropertyValue("ConstantErrorLow");
797 bSetHighAndLowValues = true;
798 break;
799 case css::chart::ChartErrorCategory_PERCENT:
800 aHigh = aLow = getPropertyValue("PercentageError");
801 bSetHighAndLowValues = true;
802 break;
803 case css::chart::ChartErrorCategory_ERROR_MARGIN:
804 aHigh = aLow = getPropertyValue("ErrorMargin");
805 bSetHighAndLowValues = true;
806 break;
807 default:
808 break;
809 }
810
811 WrappedPropertySet::setPropertyValue( rPropertyName, rValue );
812
813 if(bSetHighAndLowValues)
814 {
815 switch(aNewValue)
816 {
817 case css::chart::ChartErrorCategory_CONSTANT_VALUE:
818 setPropertyValue("ConstantErrorHigh",aHigh);
819 setPropertyValue("ConstantErrorLow",aLow);
820 break;
821 case css::chart::ChartErrorCategory_PERCENT:
822 setPropertyValue("PercentageError",aHigh);
823 break;
824 case css::chart::ChartErrorCategory_ERROR_MARGIN:
825 setPropertyValue("ErrorMargin",aHigh);
826 break;
827 default:
828 break;
829 }
830 }
831 }
832 else
833 WrappedPropertySet::setPropertyValue( rPropertyName, rValue );
834}
835
836Any SAL_CALL DataSeriesPointWrapper::getPropertyValue( const OUString& rPropertyName )
837{
838 if( m_eType == DATA_POINT )
839 {
840 if( rPropertyName == "FillColor" )
841 {
843 bool bVaryColorsByPoint = false;
844 // "VaryColorsByPoint"
845 if( xSeries.is() && (xSeries->getFastPropertyValue(PROP_DATASERIES_VARY_COLORS_BY_POINT) >>= bVaryColorsByPoint)
846 && bVaryColorsByPoint )
847 {
849 if( xPointState.is() && xPointState->getPropertyState("Color") == beans::PropertyState_DEFAULT_VALUE )
850 {
852 if( xDiagram.is() )
853 {
854 Reference< chart2::XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme() );
855 if( xColorScheme.is() )
856 return uno::Any( xColorScheme->getColorByIndex( m_nPointIndex ) );
857 }
858 }
859 }
860 }
861 }
862 return WrappedPropertySet::getPropertyValue( rPropertyName );
863}
864
866{
867 return "com.sun.star.comp.chart.DataSeries";
868}
869
870sal_Bool SAL_CALL DataSeriesPointWrapper::supportsService( const OUString& rServiceName )
871{
872 return cppu::supportsService(this, rServiceName);
873}
874
875css::uno::Sequence< OUString > SAL_CALL DataSeriesPointWrapper::getSupportedServiceNames()
876{
877 return {
878 "com.sun.star.chart.ChartDataRowProperties",
879 "com.sun.star.chart.ChartDataPointProperties",
880 "com.sun.star.xml.UserDefinedAttributesSupplier",
881 "com.sun.star.beans.PropertySet",
882 "com.sun.star.drawing.FillProperties",
883 "com.sun.star.drawing.LineProperties",
884 "com.sun.star.style.CharacterProperties"
885 };
886}
887
888} // namespace chart
889
890/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
PropertiesInfo aProperties
css::uno::Any m_aDefaultValue
PropertySetType m_eType
static bool isSupportingAreaProperties(const rtl::Reference< ::chart::ChartType > &xChartType, sal_Int32 nDimensionCount)
static bool isSeriesAttachedToMainAxis(const rtl::Reference< ::chart::DataSeries > &xDataSeries)
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
virtual css::uno::Any convertOuterToInnerValue(const css::uno::Any &rOuterValue) const
virtual css::uno::Any getPropertyDefault(const css::uno::Reference< css::beans::XPropertyState > &xInnerPropertyState) const
virtual css::uno::Any getPropertyValue(const css::uno::Reference< css::beans::XPropertySet > &xInnerPropertySet) const
virtual css::uno::Any convertInnerToOuterValue(const css::uno::Any &rInnerValue) const
virtual void setPropertyValue(const css::uno::Any &rOuterValue, const css::uno::Reference< css::beans::XPropertySet > &xInnerPropertySet) const
virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo declarations.
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
DataSeriesPointWrapper(std::shared_ptr< Chart2ModelContact > spChart2ModelContact)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
rtl::Reference< ::chart::DataSeries > getDataSeries()
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL dispose() override
::comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aEventListenerContainer
virtual std::vector< std::unique_ptr< WrappedProperty > > createWrappedProperties() override
virtual css::awt::Size getCurrentSizeForReference() override
rtl::Reference< ::chart::DataSeries > m_xDataSeries
virtual css::uno::Any getReferenceSize() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
css::uno::Reference< css::beans::XPropertySet > getDataPointProperties()
virtual const css::uno::Sequence< css::beans::Property > & getPropertySequence() override
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
static void addWrappedProperties(std::vector< std::unique_ptr< WrappedProperty > > &rList, ReferenceSizePropertyProvider *pRefSizePropProvider)
static void addWrappedPropertiesForSeries(std::vector< std::unique_ptr< WrappedProperty > > &rList, const std::shared_ptr< Chart2ModelContact > &spChart2ModelContact)
static void addProperties(std::vector< css::beans::Property > &rOutProperties)
static void addWrappedProperties(std::vector< std::unique_ptr< WrappedProperty > > &rList, const std::shared_ptr< Chart2ModelContact > &spChart2ModelContact)
static void addWrappedPropertiesForSeries(std::vector< std::unique_ptr< WrappedProperty > > &rList, const std::shared_ptr< Chart2ModelContact > &spChart2ModelContact)
static void addWrappedPropertiesForSeries(std::vector< std::unique_ptr< WrappedProperty > > &rList, const std::shared_ptr< Chart2ModelContact > &spChart2ModelContact)
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
std::mutex m_aMutex
Sequence< PropertyValue > aArguments
void * p
uno_Any a
OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector(std::vector< css::beans::Property > &rOutProperties)
void setPropertyValue(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Set a property to a certain value in the given map.
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Any SAL_CALL getCaughtException()
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
sal_Int32 nHandle
unsigned char sal_Bool
constexpr OUStringLiteral CHART_UNONAME_LABEL_BORDER_WIDTH
Definition: unonames.hxx:27
constexpr OUStringLiteral CHART_UNONAME_LABEL_BORDER_TRANS
Definition: unonames.hxx:31
constexpr OUStringLiteral CHART_UNONAME_LINK_TO_SRC_NUMFMT
Definition: unonames.hxx:21
constexpr OUStringLiteral CHART_UNONAME_LABEL_FILL_COLOR
Definition: unonames.hxx:35
constexpr OUStringLiteral CHART_UNONAME_LABEL_FILL_STYLE
Definition: unonames.hxx:32
constexpr OUStringLiteral CHART_UNONAME_NUMFMT
Definition: unonames.hxx:20
constexpr OUStringLiteral CHART_UNONAME_LABEL_FILL_BACKGROUND
Definition: unonames.hxx:33
constexpr OUStringLiteral CHART_UNONAME_LABEL_BORDER_COLOR
Definition: unonames.hxx:28
constexpr OUStringLiteral CHART_UNONAME_LABEL_BORDER_STYLE
Definition: unonames.hxx:26
constexpr OUStringLiteral CHART_UNONAME_LABEL_FILL_HATCH_NAME
Definition: unonames.hxx:34