1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "DataSeriesPointWrapper.hxx"
21 #include "Chart2ModelContact.hxx"
22 #include <ChartTypeHelper.hxx>
23 #include <DiagramHelper.hxx>
24 #include <LinePropertiesHelper.hxx>
25 #include <FillProperties.hxx>
26 #include <CharacterProperties.hxx>
27 #include <UserDefinedProperties.hxx>
28 #include "WrappedCharacterHeightProperty.hxx"
29 #include <WrappedProperty.hxx>
30 #include <WrappedIgnoreProperty.hxx>
31 #include "WrappedStatisticProperties.hxx"
32 #include "WrappedSymbolProperties.hxx"
33 #include "WrappedDataCaptionProperties.hxx"
34 #include "WrappedSeriesAreaOrLineProperty.hxx"
35 #include "WrappedScaleTextProperties.hxx"
36 #include "WrappedNumberFormatProperty.hxx"
37 #include "WrappedTextRotationProperty.hxx"
38 #include <unonames.hxx>
40 #include <rtl/math.hxx>
43 #include <cppuhelper/supportsservice.hxx>
44 #include <com/sun/star/beans/PropertyAttribute.hpp>
45 #include <com/sun/star/chart/ChartAxisAssign.hpp>
46 #include <com/sun/star/chart/ChartErrorCategory.hpp>
47 #include <com/sun/star/chart/ChartSymbolType.hpp>
48 #include <com/sun/star/drawing/LineJoint.hpp>
49 #include <com/sun/star/drawing/LineStyle.hpp>
50 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
51 #include <comphelper/sequence.hxx>
52 #include <cppuhelper/exc_hlp.hxx>
53 #include <cppuhelper/propshlp.hxx>
55 using namespace ::com::sun::star
;
56 using namespace ::chart::wrapper
;
58 using ::com::sun::star::uno::Reference
;
59 using ::com::sun::star::uno::Sequence
;
60 using ::com::sun::star::beans::Property
;
61 using ::com::sun::star::uno::Any
;
68 //data point properties
69 PROP_SERIES_DATAPOINT_SOLIDTYPE
,
70 PROP_SERIES_DATAPOINT_SEGMENT_OFFSET
,
71 PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL
,
72 PROP_SERIES_DATAPOINT_LABEL_SEPARATOR
,
73 PROP_SERIES_NUMBERFORMAT
,
74 PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE
,
75 PROP_SERIES_PERCENTAGE_NUMBERFORMAT
,
76 PROP_SERIES_DATAPOINT_TEXT_WORD_WRAP
,
77 PROP_SERIES_DATAPOINT_LABEL_PLACEMENT
,
78 //other series properties
79 PROP_SERIES_ATTACHED_AXIS
,
80 PROP_SERIES_DATAPOINT_TEXT_ROTATION
,
81 PROP_SERIES_DATAPOINT_LABEL_BORDER_STYLE
,
82 PROP_SERIES_DATAPOINT_LABEL_BORDER_WIDTH
,
83 PROP_SERIES_DATAPOINT_LABEL_BORDER_COLOR
,
84 PROP_SERIES_DATAPOINT_LABEL_BORDER_TRANS
87 void lcl_AddPropertiesToVector_PointProperties(
88 std::vector
< Property
> & rOutProperties
)
90 //service chart::Chart3DBarProperties
91 rOutProperties
.emplace_back( "SolidType",
92 PROP_SERIES_DATAPOINT_SOLIDTYPE
,
93 cppu::UnoType
<sal_Int32
>::get(),
94 beans::PropertyAttribute::BOUND
95 | beans::PropertyAttribute::MAYBEDEFAULT
);
97 rOutProperties
.emplace_back( "SegmentOffset",
98 PROP_SERIES_DATAPOINT_SEGMENT_OFFSET
,
99 cppu::UnoType
<sal_Int32
>::get(),
100 beans::PropertyAttribute::BOUND
101 | beans::PropertyAttribute::MAYBEDEFAULT
);
103 rOutProperties
.emplace_back( "D3DPercentDiagonal",
104 PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL
,
105 cppu::UnoType
<sal_Int16
>::get(),
106 beans::PropertyAttribute::BOUND
107 | beans::PropertyAttribute::MAYBEVOID
);
109 rOutProperties
.emplace_back( "LabelSeparator",
110 PROP_SERIES_DATAPOINT_LABEL_SEPARATOR
,
111 cppu::UnoType
<OUString
>::get(),
112 beans::PropertyAttribute::BOUND
113 | beans::PropertyAttribute::MAYBEDEFAULT
);
115 rOutProperties
.emplace_back( CHART_UNONAME_NUMFMT
,
116 PROP_SERIES_NUMBERFORMAT
,
117 cppu::UnoType
<sal_Int32
>::get(),
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::MAYBEVOID
);
121 rOutProperties
.emplace_back( "PercentageNumberFormat",
122 PROP_SERIES_PERCENTAGE_NUMBERFORMAT
,
123 cppu::UnoType
<sal_Int32
>::get(),
124 beans::PropertyAttribute::BOUND
125 | beans::PropertyAttribute::MAYBEVOID
);
127 rOutProperties
.emplace_back( "TextWordWrap",
128 PROP_SERIES_DATAPOINT_TEXT_WORD_WRAP
,
129 cppu::UnoType
<bool>::get(),
130 beans::PropertyAttribute::BOUND
131 | beans::PropertyAttribute::MAYBEVOID
);
133 rOutProperties
.emplace_back( "LabelPlacement",
134 PROP_SERIES_DATAPOINT_LABEL_PLACEMENT
,
135 cppu::UnoType
<sal_Int32
>::get(),
136 beans::PropertyAttribute::BOUND
137 | beans::PropertyAttribute::MAYBEVOID
);
139 rOutProperties
.emplace_back( "TextRotation",
140 PROP_SERIES_DATAPOINT_TEXT_ROTATION
,
141 cppu::UnoType
<sal_Int32
>::get(),
142 beans::PropertyAttribute::BOUND
143 | beans::PropertyAttribute::MAYBEDEFAULT
);
145 rOutProperties
.emplace_back( CHART_UNONAME_LABEL_BORDER_STYLE
,
146 PROP_SERIES_DATAPOINT_LABEL_BORDER_STYLE
,
147 cppu::UnoType
<drawing::LineStyle
>::get(),
148 beans::PropertyAttribute::BOUND
149 | beans::PropertyAttribute::MAYBEDEFAULT
);
151 rOutProperties
.emplace_back( CHART_UNONAME_LABEL_BORDER_WIDTH
,
152 PROP_SERIES_DATAPOINT_LABEL_BORDER_WIDTH
,
153 cppu::UnoType
<sal_Int32
>::get(),
154 beans::PropertyAttribute::BOUND
155 | beans::PropertyAttribute::MAYBEDEFAULT
);
157 rOutProperties
.emplace_back( CHART_UNONAME_LABEL_BORDER_COLOR
,
158 PROP_SERIES_DATAPOINT_LABEL_BORDER_COLOR
,
159 cppu::UnoType
<sal_Int32
>::get(),
160 beans::PropertyAttribute::BOUND
161 | beans::PropertyAttribute::MAYBEVOID
// "maybe auto"
162 | beans::PropertyAttribute::MAYBEDEFAULT
);
164 rOutProperties
.emplace_back( CHART_UNONAME_LABEL_BORDER_TRANS
,
165 PROP_SERIES_DATAPOINT_LABEL_BORDER_TRANS
,
166 cppu::UnoType
<sal_Int16
>::get(),
167 beans::PropertyAttribute::BOUND
168 | beans::PropertyAttribute::MAYBEDEFAULT
);
171 void lcl_AddPropertiesToVector_SeriesOnly(
172 std::vector
< Property
> & rOutProperties
)
174 rOutProperties
.emplace_back( "Axis",
175 PROP_SERIES_ATTACHED_AXIS
,
176 cppu::UnoType
<sal_Int32
>::get(),
177 beans::PropertyAttribute::BOUND
178 | beans::PropertyAttribute::MAYBEDEFAULT
);
180 rOutProperties
.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT
,
181 PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE
,
182 cppu::UnoType
<bool>::get(),
183 beans::PropertyAttribute::BOUND
184 | beans::PropertyAttribute::MAYBEDEFAULT
);
187 uno::Sequence
< Property
> lcl_GetPropertySequence( DataSeriesPointWrapper::eType _eType
)
189 std::vector
< css::beans::Property
> aProperties
;
191 lcl_AddPropertiesToVector_PointProperties( aProperties
);
192 if( _eType
== DataSeriesPointWrapper::DATA_SERIES
)
194 lcl_AddPropertiesToVector_SeriesOnly( aProperties
);
195 WrappedStatisticProperties::addProperties( aProperties
);
197 WrappedSymbolProperties::addProperties( aProperties
); //for series and points
198 WrappedDataCaptionProperties::addProperties( aProperties
); //for series and points
200 ::chart::FillProperties::AddPropertiesToVector( aProperties
);
201 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties
);
202 ::chart::CharacterProperties::AddPropertiesToVector( aProperties
);
203 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
204 ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties
);
206 std::sort( aProperties
.begin(), aProperties
.end(), ::chart::PropertyNameLess() );
208 return comphelper::containerToSequence( aProperties
);
211 struct StaticSeriesWrapperPropertyArray_Initializer
213 Sequence
< Property
>* operator()()
215 static Sequence
< Property
> aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES
) );
220 struct StaticSeriesWrapperPropertyArray
: public rtl::StaticAggregate
< Sequence
< Property
>, StaticSeriesWrapperPropertyArray_Initializer
>
224 struct StaticPointWrapperPropertyArray_Initializer
226 Sequence
< Property
>* operator()()
228 static Sequence
< Property
> aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT
) );
233 struct StaticPointWrapperPropertyArray
: public rtl::StaticAggregate
< Sequence
< Property
>, StaticPointWrapperPropertyArray_Initializer
>
237 //PROP_SERIES_ATTACHED_AXIS
238 class WrappedAttachedAxisProperty
: public ::chart::WrappedProperty
241 explicit WrappedAttachedAxisProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
);
243 virtual void setPropertyValue( const Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
245 virtual Any
getPropertyValue( const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
247 virtual Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
250 std::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
253 WrappedAttachedAxisProperty::WrappedAttachedAxisProperty(
254 const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
255 : WrappedProperty("Axis",OUString())
256 , m_spChart2ModelContact( spChart2ModelContact
)
260 Any
WrappedAttachedAxisProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
263 aRet
<<= css::chart::ChartAxisAssign::PRIMARY_Y
;
267 Any
WrappedAttachedAxisProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
271 uno::Reference
< chart2::XDataSeries
> xDataSeries( xInnerPropertySet
, uno::UNO_QUERY
);
272 bool bAttachedToMainAxis
= ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries
);
273 if( bAttachedToMainAxis
)
274 aRet
<<= css::chart::ChartAxisAssign::PRIMARY_Y
;
276 aRet
<<= css::chart::ChartAxisAssign::SECONDARY_Y
;
280 void WrappedAttachedAxisProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
282 uno::Reference
< chart2::XDataSeries
> xDataSeries( xInnerPropertySet
, uno::UNO_QUERY
);
284 sal_Int32 nChartAxisAssign
= css::chart::ChartAxisAssign::PRIMARY_Y
;
285 if( ! (rOuterValue
>>= nChartAxisAssign
) )
286 throw lang::IllegalArgumentException("Property Axis requires value of type sal_Int32", nullptr, 0 );
288 bool bNewAttachedToMainAxis
= nChartAxisAssign
== css::chart::ChartAxisAssign::PRIMARY_Y
;
289 bool bOldAttachedToMainAxis
= ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries
);
291 if( bNewAttachedToMainAxis
!= bOldAttachedToMainAxis
)
293 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
295 ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis
, xDataSeries
, xDiagram
, m_spChart2ModelContact
->m_xContext
, false );
299 class WrappedSegmentOffsetProperty
: public ::chart::WrappedProperty
302 WrappedSegmentOffsetProperty();
305 virtual Any
convertInnerToOuterValue( const Any
& rInnerValue
) const override
;
306 virtual Any
convertOuterToInnerValue( const Any
& rOuterValue
) const override
;
309 WrappedSegmentOffsetProperty::WrappedSegmentOffsetProperty() :
310 WrappedProperty("SegmentOffset","Offset")
313 Any
WrappedSegmentOffsetProperty::convertInnerToOuterValue( const Any
& rInnerValue
) const
315 // convert new double offset to former integer segment-offset
317 Any
aResult( rInnerValue
);
319 if( rInnerValue
>>= fOffset
)
320 aResult
<<= static_cast< sal_Int32
>( ::rtl::math::round( fOffset
* 100.0 ));
325 Any
WrappedSegmentOffsetProperty::convertOuterToInnerValue( const Any
& rOuterValue
) const
327 // convert former integer segment-offset to new double offset
328 sal_Int32 nOffset
= 0;
329 Any
aResult( rOuterValue
);
331 if( rOuterValue
>>= nOffset
)
332 aResult
<<= static_cast< double >( nOffset
) / 100.0;
337 class WrappedLineColorProperty
: public WrappedSeriesAreaOrLineProperty
340 explicit WrappedLineColorProperty( DataSeriesPointWrapper
* pDataSeriesPointWrapper
);
342 virtual void setPropertyValue( const Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
344 virtual void setPropertyToDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
346 virtual css::uno::Any
getPropertyDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
349 DataSeriesPointWrapper
* m_pDataSeriesPointWrapper
;
350 mutable Any m_aDefaultValue
;
353 WrappedLineColorProperty::WrappedLineColorProperty(
354 DataSeriesPointWrapper
* pDataSeriesPointWrapper
)
355 : WrappedSeriesAreaOrLineProperty("LineColor","BorderColor","Color", pDataSeriesPointWrapper
)
356 , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper
)
357 , m_aDefaultValue(uno::Any(sal_Int32( 0x0099ccff ))) // blue 8
361 void WrappedLineColorProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
363 if( !m_pDataSeriesPointWrapper
|| !m_pDataSeriesPointWrapper
->isLinesForbidden() )
364 WrappedSeriesAreaOrLineProperty::setPropertyValue( rOuterValue
, xInnerPropertySet
);
367 void WrappedLineColorProperty::setPropertyToDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
369 if( !m_pDataSeriesPointWrapper
|| !m_pDataSeriesPointWrapper
->isLinesForbidden() )
370 WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState
);
373 Any
WrappedLineColorProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
375 if( m_pDataSeriesPointWrapper
&& !m_pDataSeriesPointWrapper
->isSupportingAreaProperties() )
376 return m_aDefaultValue
;
378 return WrappedSeriesAreaOrLineProperty::getPropertyDefault( xInnerPropertyState
);
381 class WrappedLineStyleProperty
: public WrappedSeriesAreaOrLineProperty
384 explicit WrappedLineStyleProperty( DataSeriesPointWrapper
* pDataSeriesPointWrapper
);
386 virtual void setPropertyValue( const Any
& rOuterValue
, const css::uno::Reference
< css::beans::XPropertySet
>& xInnerPropertySet
) const override
;
388 virtual void setPropertyToDefault( const css::uno::Reference
< css::beans::XPropertyState
>& xInnerPropertyState
) const override
;
391 DataSeriesPointWrapper
* m_pDataSeriesPointWrapper
;
394 WrappedLineStyleProperty::WrappedLineStyleProperty(
395 DataSeriesPointWrapper
* pDataSeriesPointWrapper
)
396 : WrappedSeriesAreaOrLineProperty("LineStyle","BorderStyle", "LineStyle", pDataSeriesPointWrapper
)
397 , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper
)
401 void WrappedLineStyleProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
403 Any
aNewValue(rOuterValue
);
404 if( m_pDataSeriesPointWrapper
&& m_pDataSeriesPointWrapper
->isLinesForbidden() )
406 aNewValue
<<= drawing::LineStyle_NONE
;
408 WrappedSeriesAreaOrLineProperty::setPropertyValue( aNewValue
, xInnerPropertySet
);
411 void WrappedLineStyleProperty::setPropertyToDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
413 if( !m_pDataSeriesPointWrapper
|| !m_pDataSeriesPointWrapper
->isLinesForbidden() )
414 WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState
);
417 } // anonymous namespace
424 DataSeriesPointWrapper::DataSeriesPointWrapper(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
425 : m_spChart2ModelContact( spChart2ModelContact
)
426 , m_aEventListenerContainer( m_aMutex
)
427 , m_eType( DATA_SERIES
)
428 , m_nSeriesIndexInNewAPI( -1 )
429 , m_nPointIndex( -1 )
430 , m_bLinesAllowed(true)
432 //need initialize call afterwards
435 void SAL_CALL
DataSeriesPointWrapper::initialize( const uno::Sequence
< uno::Any
>& aArguments
)
437 OSL_PRECOND(aArguments
.hasElements(),"need at least 1 argument to initialize the DataSeriesPointWrapper: series reference + optional datapoint index");
439 m_nSeriesIndexInNewAPI
= -1;//ignored in this case
441 if( aArguments
.hasElements() )
443 aArguments
[0] >>= m_xDataSeries
;
444 if( aArguments
.getLength() >= 2 )
445 aArguments
[1] >>= m_nPointIndex
;
448 if( !m_xDataSeries
.is() )
449 throw uno::Exception(
450 "DataSeries index invalid", static_cast< ::cppu::OWeakObject
* >( this ));
452 //todo: check upper border of point index
454 if( m_nPointIndex
>= 0 )
455 m_eType
= DATA_POINT
;
457 m_eType
= DATA_SERIES
;
460 DataSeriesPointWrapper::DataSeriesPointWrapper(eType _eType
,
461 sal_Int32 nSeriesIndexInNewAPI
,
462 sal_Int32 nPointIndex
, //ignored for series
463 const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
464 : m_spChart2ModelContact( spChart2ModelContact
)
465 , m_aEventListenerContainer( m_aMutex
)
467 , m_nSeriesIndexInNewAPI( nSeriesIndexInNewAPI
)
468 , m_nPointIndex( (_eType
== DATA_POINT
) ? nPointIndex
: -1 )
469 , m_bLinesAllowed( false )
473 DataSeriesPointWrapper::~DataSeriesPointWrapper()
477 // ____ XComponent ____
478 void SAL_CALL
DataSeriesPointWrapper::dispose()
480 uno::Reference
< uno::XInterface
> xSource( static_cast< ::cppu::OWeakObject
* >( this ) );
481 m_aEventListenerContainer
.disposeAndClear( lang::EventObject( xSource
) );
483 m_xDataSeries
.clear();
484 clearWrappedPropertySet();
487 void SAL_CALL
DataSeriesPointWrapper::addEventListener(
488 const uno::Reference
< lang::XEventListener
>& xListener
)
490 m_aEventListenerContainer
.addInterface( xListener
);
493 void SAL_CALL
DataSeriesPointWrapper::removeEventListener(
494 const uno::Reference
< lang::XEventListener
>& aListener
)
496 m_aEventListenerContainer
.removeInterface( aListener
);
499 // ____ XEventListener ____
500 void SAL_CALL
DataSeriesPointWrapper::disposing( const lang::EventObject
& /*Source*/ )
504 bool DataSeriesPointWrapper::isSupportingAreaProperties()
506 Reference
< chart2::XDataSeries
> xSeries( getDataSeries() );
507 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
508 Reference
< chart2::XChartType
> xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram
, xSeries
) );
509 sal_Int32 nDimensionCount
= DiagramHelper::getDimension( xDiagram
);
511 return ChartTypeHelper::isSupportingAreaProperties( xChartType
, nDimensionCount
);
514 Reference
< chart2::XDataSeries
> DataSeriesPointWrapper::getDataSeries()
516 Reference
< chart2::XDataSeries
> xSeries( m_xDataSeries
);
519 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
520 std::vector
< uno::Reference
< chart2::XDataSeries
> > aSeriesList(
521 ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
523 if( m_nSeriesIndexInNewAPI
>= 0 && m_nSeriesIndexInNewAPI
< static_cast<sal_Int32
>(aSeriesList
.size()) )
524 xSeries
= aSeriesList
[m_nSeriesIndexInNewAPI
];
530 Reference
< beans::XPropertySet
> DataSeriesPointWrapper::getDataPointProperties()
532 Reference
< beans::XPropertySet
> xPointProp
;
534 Reference
< chart2::XDataSeries
> xSeries( getDataSeries() );
536 // may throw an IllegalArgumentException
538 xPointProp
= xSeries
->getDataPointByIndex( m_nPointIndex
);
543 //ReferenceSizePropertyProvider
544 void DataSeriesPointWrapper::updateReferenceSize()
546 Reference
< beans::XPropertySet
> xProp
= getInnerPropertySet();
549 if( xProp
->getPropertyValue("ReferencePageSize").hasValue() )
550 xProp
->setPropertyValue("ReferencePageSize", uno::Any(
551 m_spChart2ModelContact
->GetPageSize() ));
554 Any
DataSeriesPointWrapper::getReferenceSize()
557 Reference
< beans::XPropertySet
> xProp
= getInnerPropertySet();
559 aRet
= xProp
->getPropertyValue("ReferencePageSize");
562 awt::Size
DataSeriesPointWrapper::getCurrentSizeForReference()
564 return m_spChart2ModelContact
->GetPageSize();
567 // WrappedPropertySet
570 beans::PropertyState SAL_CALL
DataSeriesPointWrapper::getPropertyState( const OUString
& rPropertyName
)
572 beans::PropertyState
aState( beans::PropertyState_DIRECT_VALUE
);
575 if (rPropertyName
== "SymbolBitmap" || rPropertyName
== "SymbolBitmapURL")
577 uno::Any aAny
= WrappedPropertySet::getPropertyValue("SymbolType");
578 sal_Int32 nVal
= css::chart::ChartSymbolType::NONE
;
581 if (nVal
!= css::chart::ChartSymbolType::BITMAPURL
)
582 return beans::PropertyState::PropertyState_DEFAULT_VALUE
;
586 if( m_eType
== DATA_SERIES
)
587 aState
= WrappedPropertySet::getPropertyState( rPropertyName
);
590 if( rPropertyName
== "FillColor")
592 Reference
< beans::XPropertySet
> xSeriesProp( getDataSeries(), uno::UNO_QUERY
);
593 bool bVaryColorsByPoint
= false;
594 if( xSeriesProp
.is() && (xSeriesProp
->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint
)
595 && bVaryColorsByPoint
)
596 return beans::PropertyState_DIRECT_VALUE
;
598 else if( rPropertyName
== "Lines"
599 || rPropertyName
== "SymbolType"
600 || rPropertyName
== "SymbolSize" )
601 return WrappedPropertySet::getPropertyState( rPropertyName
);
603 uno::Any
aDefault( getPropertyDefault( rPropertyName
) );
604 uno::Any
aValue( getPropertyValue( rPropertyName
) );
605 if( aDefault
==aValue
)
606 aState
= beans::PropertyState_DEFAULT_VALUE
;
609 catch( const beans::UnknownPropertyException
& )
613 catch( const uno::RuntimeException
& )
617 catch( const lang::WrappedTargetException
& e
)
619 css::uno::Any
a(e
.TargetException
);
620 throw css::lang::WrappedTargetRuntimeException(
621 "wrapped Exception " + e
.Message
,
622 css::uno::Reference
<css::uno::XInterface
>(), a
);
624 catch( const uno::Exception
& e
)
626 css::uno::Any
a(cppu::getCaughtException());
627 throw css::lang::WrappedTargetRuntimeException(
628 "wrapped Exception " + e
.Message
,
629 css::uno::Reference
<css::uno::XInterface
>(), a
);
634 void SAL_CALL
DataSeriesPointWrapper::setPropertyToDefault( const OUString
& rPropertyName
)
636 if( m_eType
== DATA_SERIES
)
637 WrappedPropertySet::setPropertyToDefault( rPropertyName
);
640 //for data points the default is given by the series
641 setPropertyValue( rPropertyName
, getPropertyDefault( rPropertyName
) );
644 Any SAL_CALL
DataSeriesPointWrapper::getPropertyDefault( const OUString
& rPropertyName
)
649 sal_Int32 nHandle
= getInfoHelper().getHandleByName( rPropertyName
);
652 //always take the series current value as default for points
653 Reference
< beans::XPropertySet
> xInnerPropertySet( getDataSeries(), uno::UNO_QUERY
);
654 if( xInnerPropertySet
.is() )
656 const WrappedProperty
* pWrappedProperty
= getWrappedProperty( rPropertyName
);
657 if( pWrappedProperty
)
658 aRet
= pWrappedProperty
->getPropertyValue(xInnerPropertySet
);
660 aRet
= xInnerPropertySet
->getPropertyValue( rPropertyName
);
664 catch( const beans::UnknownPropertyException
& )
666 aRet
= WrappedPropertySet::getPropertyDefault( rPropertyName
);
671 Reference
< beans::XPropertySet
> DataSeriesPointWrapper::getInnerPropertySet()
673 if( m_eType
== DATA_SERIES
)
674 return Reference
< beans::XPropertySet
>( getDataSeries(), uno::UNO_QUERY
);
675 return getDataPointProperties();
678 const Sequence
< beans::Property
>& DataSeriesPointWrapper::getPropertySequence()
680 if( m_eType
== DATA_SERIES
)
681 return *StaticSeriesWrapperPropertyArray::get();
683 return *StaticPointWrapperPropertyArray::get();
686 std::vector
< std::unique_ptr
<WrappedProperty
> > DataSeriesPointWrapper::createWrappedProperties()
688 std::vector
< std::unique_ptr
<WrappedProperty
> > aWrappedProperties
;
690 WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties
, this );
692 if( m_eType
== DATA_SERIES
)
694 WrappedStatisticProperties::addWrappedPropertiesForSeries( aWrappedProperties
, m_spChart2ModelContact
);
695 aWrappedProperties
.emplace_back( new WrappedAttachedAxisProperty( m_spChart2ModelContact
) );
697 aWrappedProperties
.emplace_back( new WrappedNumberFormatProperty(m_spChart2ModelContact
) );
698 aWrappedProperties
.emplace_back( new WrappedLinkNumberFormatProperty
);
701 WrappedSymbolProperties::addWrappedPropertiesForSeries( aWrappedProperties
, m_spChart2ModelContact
);
702 WrappedDataCaptionProperties::addWrappedPropertiesForSeries( aWrappedProperties
, m_spChart2ModelContact
);
703 WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties
, m_spChart2ModelContact
);
705 //add unnamed line properties (different inner names here)
707 aWrappedProperties
.emplace_back( new WrappedProperty("FillColor","Color") );
708 aWrappedProperties
.emplace_back( new WrappedLineStyleProperty( this ) );
709 aWrappedProperties
.emplace_back( new WrappedLineColorProperty( this ) );
710 aWrappedProperties
.emplace_back( new WrappedSeriesAreaOrLineProperty("LineDashName","BorderDashName","LineDashName", this ) );
711 aWrappedProperties
.emplace_back( new WrappedSeriesAreaOrLineProperty("LineTransparence","BorderTransparency","Transparency", this ) );
712 aWrappedProperties
.emplace_back( new WrappedSeriesAreaOrLineProperty("LineWidth","BorderWidth","LineWidth", this ) );
713 aWrappedProperties
.emplace_back( new WrappedProperty("FillStyle","FillStyle" ) );
714 aWrappedProperties
.emplace_back( new WrappedProperty("FillTransparence","Transparency") );
716 aWrappedProperties
.emplace_back( new WrappedIgnoreProperty("LineJoint", uno::Any( drawing::LineJoint_ROUND
) ) );
717 aWrappedProperties
.emplace_back( new WrappedProperty("FillTransparenceGradientName","TransparencyGradientName") );
718 aWrappedProperties
.emplace_back( new WrappedProperty("FillGradientName","GradientName") );
719 aWrappedProperties
.emplace_back( new WrappedProperty("FillGradientStepCount","GradientStepCount") );
720 aWrappedProperties
.emplace_back( new WrappedProperty("FillHatchName","HatchName") );
721 aWrappedProperties
.emplace_back( new WrappedProperty("FillBitmapName","FillBitmapName") );
722 aWrappedProperties
.emplace_back( new WrappedProperty("FillBackground","FillBackground") );
725 aWrappedProperties
.emplace_back( new WrappedProperty("FillBitmapMode","FillBitmapMode") );
726 aWrappedProperties
.emplace_back( new WrappedProperty("FillBitmapSizeX","FillBitmapSizeX") );
727 aWrappedProperties
.emplace_back( new WrappedProperty("FillBitmapSizeY","FillBitmapSizeY") );
728 aWrappedProperties
.emplace_back( new WrappedProperty("FillBitmapLogicalSize","FillBitmapLogicalSize") );
729 aWrappedProperties
.emplace_back( new WrappedProperty("FillBitmapOffsetX","FillBitmapOffsetX") );
730 aWrappedProperties
.emplace_back( new WrappedProperty("FillBitmapOffsetY","FillBitmapOffsetY") );
731 aWrappedProperties
.emplace_back( new WrappedProperty("FillBitmapRectanglePoint","FillBitmapRectanglePoint") );
732 aWrappedProperties
.emplace_back( new WrappedProperty("FillBitmapPositionOffsetX","FillBitmapPositionOffsetX") );
733 aWrappedProperties
.emplace_back( new WrappedProperty("FillBitmapPositionOffsetY","FillBitmapPositionOffsetY") );
735 aWrappedProperties
.emplace_back( new WrappedProperty("SolidType","Geometry3D") );
736 aWrappedProperties
.emplace_back( new WrappedSegmentOffsetProperty() );
737 aWrappedProperties
.emplace_back( new WrappedProperty("D3DPercentDiagonal","PercentDiagonal") );
739 aWrappedProperties
.emplace_back( new WrappedTextRotationProperty() );
741 return aWrappedProperties
;
744 void SAL_CALL
DataSeriesPointWrapper::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
746 if(rPropertyName
== "Lines")
748 if( ! (rValue
>>= m_bLinesAllowed
) )
749 throw lang::IllegalArgumentException("Property Lines requires value of type sal_Bool", nullptr, 0 );
752 sal_Int32 nHandle
= getInfoHelper().getHandleByName( rPropertyName
);
753 static const sal_Int32 nErrorCategoryHandle
= getInfoHelper().getHandleByName("ErrorCategory");
754 if( nErrorCategoryHandle
== nHandle
)
756 css::chart::ChartErrorCategory aNewValue
= css::chart::ChartErrorCategory_NONE
;
757 rValue
>>= aNewValue
;
759 bool bSetHighAndLowValues
= false;
762 case css::chart::ChartErrorCategory_CONSTANT_VALUE
:
763 aHigh
= getPropertyValue("ConstantErrorHigh");
764 aLow
= getPropertyValue("ConstantErrorLow");
765 bSetHighAndLowValues
= true;
767 case css::chart::ChartErrorCategory_PERCENT
:
768 aHigh
= aLow
= getPropertyValue("PercentageError");
769 bSetHighAndLowValues
= true;
771 case css::chart::ChartErrorCategory_ERROR_MARGIN
:
772 aHigh
= aLow
= getPropertyValue("ErrorMargin");
773 bSetHighAndLowValues
= true;
779 WrappedPropertySet::setPropertyValue( rPropertyName
, rValue
);
781 if(bSetHighAndLowValues
)
785 case css::chart::ChartErrorCategory_CONSTANT_VALUE
:
786 setPropertyValue("ConstantErrorHigh",aHigh
);
787 setPropertyValue("ConstantErrorLow",aLow
);
789 case css::chart::ChartErrorCategory_PERCENT
:
790 setPropertyValue("PercentageError",aHigh
);
792 case css::chart::ChartErrorCategory_ERROR_MARGIN
:
793 setPropertyValue("ErrorMargin",aHigh
);
801 WrappedPropertySet::setPropertyValue( rPropertyName
, rValue
);
804 Any SAL_CALL
DataSeriesPointWrapper::getPropertyValue( const OUString
& rPropertyName
)
806 if( m_eType
== DATA_POINT
)
808 if( rPropertyName
== "FillColor" )
810 Reference
< beans::XPropertySet
> xSeriesProp( getDataSeries(), uno::UNO_QUERY
);
811 bool bVaryColorsByPoint
= false;
812 if( xSeriesProp
.is() && (xSeriesProp
->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint
)
813 && bVaryColorsByPoint
)
815 uno::Reference
< beans::XPropertyState
> xPointState( DataSeriesPointWrapper::getDataPointProperties(), uno::UNO_QUERY
);
816 if( xPointState
.is() && xPointState
->getPropertyState("Color") == beans::PropertyState_DEFAULT_VALUE
)
818 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
821 Reference
< chart2::XColorScheme
> xColorScheme( xDiagram
->getDefaultColorScheme() );
822 if( xColorScheme
.is() )
823 return uno::Any( xColorScheme
->getColorByIndex( m_nPointIndex
) );
829 return WrappedPropertySet::getPropertyValue( rPropertyName
);
832 OUString SAL_CALL
DataSeriesPointWrapper::getImplementationName()
834 return "com.sun.star.comp.chart.DataSeries";
837 sal_Bool SAL_CALL
DataSeriesPointWrapper::supportsService( const OUString
& rServiceName
)
839 return cppu::supportsService(this, rServiceName
);
842 css::uno::Sequence
< OUString
> SAL_CALL
DataSeriesPointWrapper::getSupportedServiceNames()
845 "com.sun.star.chart.ChartDataRowProperties",
846 "com.sun.star.chart.ChartDataPointProperties",
847 "com.sun.star.xml.UserDefinedAttributesSupplier",
848 "com.sun.star.beans.PropertySet",
849 "com.sun.star.drawing.FillProperties",
850 "com.sun.star.drawing.LineProperties",
851 "com.sun.star.style.CharacterProperties"
855 } // namespace wrapper
858 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */