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"
22 #include "RegressionCurveHelper.hxx"
23 #include "Chart2ModelContact.hxx"
24 #include "ChartTypeHelper.hxx"
25 #include "DiagramHelper.hxx"
26 #include "ContainerHelper.hxx"
27 #include "ChartModelHelper.hxx"
28 #include "LinePropertiesHelper.hxx"
29 #include "FillProperties.hxx"
30 #include "CharacterProperties.hxx"
31 #include "UserDefinedProperties.hxx"
32 #include "WrappedCharacterHeightProperty.hxx"
33 #include "WrappedProperty.hxx"
34 #include "WrappedIgnoreProperty.hxx"
35 #include "WrappedStatisticProperties.hxx"
36 #include "WrappedSymbolProperties.hxx"
37 #include "WrappedDataCaptionProperties.hxx"
38 #include "WrappedSeriesAreaOrLineProperty.hxx"
39 #include "WrappedScaleTextProperties.hxx"
40 #include "WrappedNumberFormatProperty.hxx"
41 #include "WrappedTextRotationProperty.hxx"
42 #include <unonames.hxx>
44 #include <rtl/ustrbuf.hxx>
45 #include <rtl/math.hxx>
48 #include <comphelper/InlineContainer.hxx>
49 #include <cppuhelper/supportsservice.hxx>
50 #include <com/sun/star/beans/PropertyAttribute.hpp>
51 #include <com/sun/star/chart/ChartAxisAssign.hpp>
52 #include <com/sun/star/chart/ChartErrorCategory.hpp>
53 #include <com/sun/star/chart/ChartSymbolType.hpp>
54 #include <com/sun/star/chart/XChartDocument.hpp>
55 #include <com/sun/star/drawing/FillStyle.hpp>
56 #include <com/sun/star/drawing/LineJoint.hpp>
57 #include <com/sun/star/drawing/LineStyle.hpp>
58 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
59 #include <cppuhelper/exc_hlp.hxx>
61 using namespace ::com::sun::star
;
62 using namespace ::chart::wrapper
;
64 using ::com::sun::star::uno::Reference
;
65 using ::com::sun::star::uno::Sequence
;
66 using ::com::sun::star::beans::Property
;
67 using ::com::sun::star::uno::Any
;
68 using ::osl::MutexGuard
;
72 static const char lcl_aServiceName
[] = "com.sun.star.comp.chart.DataSeries";
76 //data point properties
77 PROP_SERIES_DATAPOINT_SOLIDTYPE
,
78 PROP_SERIES_DATAPOINT_SEGMENT_OFFSET
,
79 PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL
,
80 PROP_SERIES_DATAPOINT_LABEL_SEPARATOR
,
81 PROP_SERIES_NUMBERFORMAT
,
82 PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE
,
83 PROP_SERIES_PERCENTAGE_NUMBERFORMAT
,
84 PROP_SERIES_DATAPOINT_LABEL_PLACEMENT
,
85 //other series properties
86 PROP_SERIES_ATTACHED_AXIS
,
87 PROP_SERIES_DATAPOINT_TEXT_ROTATION
,
88 PROP_SERIES_DATAPOINT_LABEL_BORDER_STYLE
,
89 PROP_SERIES_DATAPOINT_LABEL_BORDER_WIDTH
,
90 PROP_SERIES_DATAPOINT_LABEL_BORDER_COLOR
,
91 PROP_SERIES_DATAPOINT_LABEL_BORDER_TRANS
94 void lcl_AddPropertiesToVector_PointProperties(
95 ::std::vector
< Property
> & rOutProperties
)
97 //service chart::Chart3DBarProperties
98 rOutProperties
.push_back(
99 Property( "SolidType",
100 PROP_SERIES_DATAPOINT_SOLIDTYPE
,
101 cppu::UnoType
<sal_Int32
>::get(),
102 beans::PropertyAttribute::BOUND
103 | beans::PropertyAttribute::MAYBEDEFAULT
));
105 rOutProperties
.push_back(
106 Property( "SegmentOffset",
107 PROP_SERIES_DATAPOINT_SEGMENT_OFFSET
,
108 cppu::UnoType
<sal_Int32
>::get(),
109 beans::PropertyAttribute::BOUND
110 | beans::PropertyAttribute::MAYBEDEFAULT
));
112 rOutProperties
.push_back(
113 Property( "D3DPercentDiagonal",
114 PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL
,
115 cppu::UnoType
<sal_Int16
>::get(),
116 beans::PropertyAttribute::BOUND
117 | beans::PropertyAttribute::MAYBEVOID
));
119 rOutProperties
.push_back(
120 Property( "LabelSeparator",
121 PROP_SERIES_DATAPOINT_LABEL_SEPARATOR
,
122 cppu::UnoType
<OUString
>::get(),
123 beans::PropertyAttribute::BOUND
124 | beans::PropertyAttribute::MAYBEDEFAULT
));
126 rOutProperties
.push_back(
127 Property( CHART_UNONAME_NUMFMT
,
128 PROP_SERIES_NUMBERFORMAT
,
129 cppu::UnoType
<sal_Int32
>::get(),
130 beans::PropertyAttribute::BOUND
131 | beans::PropertyAttribute::MAYBEVOID
));
133 rOutProperties
.push_back(
134 Property( "PercentageNumberFormat",
135 PROP_SERIES_PERCENTAGE_NUMBERFORMAT
,
136 cppu::UnoType
<sal_Int32
>::get(),
137 beans::PropertyAttribute::BOUND
138 | beans::PropertyAttribute::MAYBEVOID
));
140 rOutProperties
.push_back(
141 Property( "LabelPlacement",
142 PROP_SERIES_DATAPOINT_LABEL_PLACEMENT
,
143 cppu::UnoType
<sal_Int32
>::get(),
144 beans::PropertyAttribute::BOUND
145 | beans::PropertyAttribute::MAYBEVOID
));
147 rOutProperties
.push_back(
148 Property( "TextRotation",
149 PROP_SERIES_DATAPOINT_TEXT_ROTATION
,
150 cppu::UnoType
<sal_Int32
>::get(),
151 beans::PropertyAttribute::BOUND
152 | beans::PropertyAttribute::MAYBEDEFAULT
));
154 rOutProperties
.push_back(
155 Property( CHART_UNONAME_LABEL_BORDER_STYLE
,
156 PROP_SERIES_DATAPOINT_LABEL_BORDER_STYLE
,
157 cppu::UnoType
<drawing::LineStyle
>::get(),
158 beans::PropertyAttribute::BOUND
159 | beans::PropertyAttribute::MAYBEDEFAULT
));
161 rOutProperties
.push_back(
162 Property( CHART_UNONAME_LABEL_BORDER_WIDTH
,
163 PROP_SERIES_DATAPOINT_LABEL_BORDER_WIDTH
,
164 cppu::UnoType
<sal_Int32
>::get(),
165 beans::PropertyAttribute::BOUND
166 | beans::PropertyAttribute::MAYBEDEFAULT
));
168 rOutProperties
.push_back(
169 Property( CHART_UNONAME_LABEL_BORDER_COLOR
,
170 PROP_SERIES_DATAPOINT_LABEL_BORDER_COLOR
,
171 cppu::UnoType
<sal_Int32
>::get(),
172 beans::PropertyAttribute::BOUND
173 | beans::PropertyAttribute::MAYBEVOID
// "maybe auto"
174 | beans::PropertyAttribute::MAYBEDEFAULT
));
176 rOutProperties
.push_back(
177 Property( CHART_UNONAME_LABEL_BORDER_TRANS
,
178 PROP_SERIES_DATAPOINT_LABEL_BORDER_TRANS
,
179 cppu::UnoType
<sal_Int16
>::get(),
180 beans::PropertyAttribute::BOUND
181 | beans::PropertyAttribute::MAYBEDEFAULT
));
184 void lcl_AddPropertiesToVector_SeriesOnly(
185 ::std::vector
< Property
> & rOutProperties
)
187 rOutProperties
.push_back(
189 PROP_SERIES_ATTACHED_AXIS
,
190 cppu::UnoType
<sal_Int32
>::get(),
191 beans::PropertyAttribute::BOUND
192 | beans::PropertyAttribute::MAYBEDEFAULT
));
194 rOutProperties
.push_back(
195 Property( CHART_UNONAME_LINK_TO_SRC_NUMFMT
,
196 PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE
,
197 cppu::UnoType
<bool>::get(),
198 beans::PropertyAttribute::BOUND
199 | beans::PropertyAttribute::MAYBEDEFAULT
));
202 uno::Sequence
< Property
> lcl_GetPropertySequence( DataSeriesPointWrapper::eType _eType
)
204 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
206 lcl_AddPropertiesToVector_PointProperties( aProperties
);
207 if( _eType
== DataSeriesPointWrapper::DATA_SERIES
)
209 lcl_AddPropertiesToVector_SeriesOnly( aProperties
);
210 WrappedStatisticProperties::addProperties( aProperties
);
212 WrappedSymbolProperties::addProperties( aProperties
); //for series and points
213 WrappedDataCaptionProperties::addProperties( aProperties
); //for series and points
215 ::chart::FillProperties::AddPropertiesToVector( aProperties
);
216 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties
);
217 ::chart::CharacterProperties::AddPropertiesToVector( aProperties
);
218 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
219 ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties
);
221 ::std::sort( aProperties
.begin(), aProperties
.end(), ::chart::PropertyNameLess() );
223 return ::chart::ContainerHelper::ContainerToSequence( aProperties
);
226 struct StaticSeriesWrapperPropertyArray_Initializer
228 Sequence
< Property
>* operator()()
230 static Sequence
< Property
> aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES
) );
235 struct StaticSeriesWrapperPropertyArray
: public rtl::StaticAggregate
< Sequence
< Property
>, StaticSeriesWrapperPropertyArray_Initializer
>
239 struct StaticPointWrapperPropertyArray_Initializer
241 Sequence
< Property
>* operator()()
243 static Sequence
< Property
> aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT
) );
248 struct StaticPointWrapperPropertyArray
: public rtl::StaticAggregate
< Sequence
< Property
>, StaticPointWrapperPropertyArray_Initializer
>
252 //PROP_SERIES_ATTACHED_AXIS
253 class WrappedAttachedAxisProperty
: public ::chart::WrappedProperty
256 WrappedAttachedAxisProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
);
257 virtual ~WrappedAttachedAxisProperty();
259 virtual void setPropertyValue( const Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
260 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
262 virtual Any
getPropertyValue( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
263 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
265 virtual Any
getPropertyDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
266 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
269 ::boost::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
272 WrappedAttachedAxisProperty::WrappedAttachedAxisProperty(
273 ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
274 : WrappedProperty("Axis",OUString())
275 , m_spChart2ModelContact( spChart2ModelContact
)
279 WrappedAttachedAxisProperty::~WrappedAttachedAxisProperty()
283 Any
WrappedAttachedAxisProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
284 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
287 aRet
<<= ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y
;
291 Any
WrappedAttachedAxisProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
292 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
296 uno::Reference
< chart2::XDataSeries
> xDataSeries( xInnerPropertySet
, uno::UNO_QUERY
);
297 bool bAttachedToMainAxis
= ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries
);
298 if( bAttachedToMainAxis
)
299 aRet
<<= ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y
;
301 aRet
<<= ::com::sun::star::chart::ChartAxisAssign::SECONDARY_Y
;
305 void WrappedAttachedAxisProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
306 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
308 uno::Reference
< chart2::XDataSeries
> xDataSeries( xInnerPropertySet
, uno::UNO_QUERY
);
310 sal_Int32 nChartAxisAssign
= ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y
;
311 if( ! (rOuterValue
>>= nChartAxisAssign
) )
312 throw lang::IllegalArgumentException("Property Axis requires value of type sal_Int32", 0, 0 );
314 bool bNewAttachedToMainAxis
= nChartAxisAssign
== ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y
;
315 bool bOldAttachedToMainAxis
= ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries
);
317 if( bNewAttachedToMainAxis
!= bOldAttachedToMainAxis
)
319 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
321 ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis
, xDataSeries
, xDiagram
, m_spChart2ModelContact
->m_xContext
, false );
325 class WrappedSegmentOffsetProperty
: public ::chart::WrappedProperty
328 WrappedSegmentOffsetProperty();
329 virtual ~WrappedSegmentOffsetProperty();
332 virtual Any
convertInnerToOuterValue( const Any
& rInnerValue
) const SAL_OVERRIDE
;
333 virtual Any
convertOuterToInnerValue( const Any
& rOuterValue
) const SAL_OVERRIDE
;
336 WrappedSegmentOffsetProperty::WrappedSegmentOffsetProperty() :
337 WrappedProperty("SegmentOffset","Offset")
340 WrappedSegmentOffsetProperty::~WrappedSegmentOffsetProperty()
343 Any
WrappedSegmentOffsetProperty::convertInnerToOuterValue( const Any
& rInnerValue
) const
345 // convert new double offset to former integer segment-offset
347 Any
aResult( rInnerValue
);
349 if( rInnerValue
>>= fOffset
)
350 aResult
<<= static_cast< sal_Int32
>( ::rtl::math::round( fOffset
* 100.0 ));
355 Any
WrappedSegmentOffsetProperty::convertOuterToInnerValue( const Any
& rOuterValue
) const
357 // convert former integer segment-offset to new double offset
358 sal_Int32 nOffset
= 0;
359 Any
aResult( rOuterValue
);
361 if( rOuterValue
>>= nOffset
)
362 aResult
<<= (static_cast< double >( nOffset
) / 100.0);
367 class WrappedLineColorProperty
: public WrappedSeriesAreaOrLineProperty
370 WrappedLineColorProperty( DataSeriesPointWrapper
* pDataSeriesPointWrapper
);
371 virtual ~WrappedLineColorProperty();
373 virtual void setPropertyValue( const Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
374 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
376 virtual void setPropertyToDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
377 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
379 virtual ::com::sun::star::uno::Any
getPropertyDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
380 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
383 DataSeriesPointWrapper
* m_pDataSeriesPointWrapper
;
384 mutable Any m_aDefaultValue
;
385 mutable Any m_aOuterValue
;
388 WrappedLineColorProperty::WrappedLineColorProperty(
389 DataSeriesPointWrapper
* pDataSeriesPointWrapper
)
390 : WrappedSeriesAreaOrLineProperty("LineColor","BorderColor","Color", pDataSeriesPointWrapper
)
391 , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper
)
392 , m_aDefaultValue(uno::makeAny(sal_Int32( 0x0099ccff ))) // blue 8
393 , m_aOuterValue(m_aDefaultValue
)
397 WrappedLineColorProperty::~WrappedLineColorProperty()
401 void WrappedLineColorProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
402 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
404 if( m_pDataSeriesPointWrapper
&& m_pDataSeriesPointWrapper
->isLinesForbidden() )
405 m_aOuterValue
= rOuterValue
;
407 WrappedSeriesAreaOrLineProperty::setPropertyValue( rOuterValue
, xInnerPropertySet
);
410 void WrappedLineColorProperty::setPropertyToDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
411 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
)
413 if( m_pDataSeriesPointWrapper
&& m_pDataSeriesPointWrapper
->isLinesForbidden() )
414 m_aOuterValue
= m_aDefaultValue
;
416 WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState
);
419 Any
WrappedLineColorProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
420 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
422 if( m_pDataSeriesPointWrapper
&& !m_pDataSeriesPointWrapper
->isSupportingAreaProperties() )
423 return m_aDefaultValue
;
425 return WrappedSeriesAreaOrLineProperty::getPropertyDefault( xInnerPropertyState
);
428 class WrappedLineStyleProperty
: public WrappedSeriesAreaOrLineProperty
431 WrappedLineStyleProperty( DataSeriesPointWrapper
* pDataSeriesPointWrapper
);
432 virtual ~WrappedLineStyleProperty();
434 virtual void setPropertyValue( const Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
435 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
437 virtual void setPropertyToDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
438 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
441 DataSeriesPointWrapper
* m_pDataSeriesPointWrapper
;
442 mutable Any m_aDefaultValue
;
443 mutable Any m_aOuterValue
;
446 WrappedLineStyleProperty::WrappedLineStyleProperty(
447 DataSeriesPointWrapper
* pDataSeriesPointWrapper
)
448 : WrappedSeriesAreaOrLineProperty("LineStyle","BorderStyle", "LineStyle", pDataSeriesPointWrapper
)
449 , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper
)
450 , m_aDefaultValue(uno::makeAny(drawing::LineStyle_SOLID
))
451 , m_aOuterValue(m_aDefaultValue
)
455 WrappedLineStyleProperty::~WrappedLineStyleProperty()
459 void WrappedLineStyleProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
460 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
462 Any
aNewValue(rOuterValue
);
463 if( m_pDataSeriesPointWrapper
&& m_pDataSeriesPointWrapper
->isLinesForbidden() )
465 m_aOuterValue
= rOuterValue
;
466 aNewValue
= uno::makeAny(drawing::LineStyle_NONE
);
468 WrappedSeriesAreaOrLineProperty::setPropertyValue( aNewValue
, xInnerPropertySet
);
471 void WrappedLineStyleProperty::setPropertyToDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
472 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
)
474 if( m_pDataSeriesPointWrapper
&& m_pDataSeriesPointWrapper
->isLinesForbidden() )
475 m_aOuterValue
= m_aDefaultValue
;
477 WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState
);
480 } // anonymous namespace
487 DataSeriesPointWrapper::DataSeriesPointWrapper(
488 ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
489 : m_spChart2ModelContact( spChart2ModelContact
)
490 , m_aEventListenerContainer( m_aMutex
)
491 , m_eType( DATA_SERIES
)
492 , m_nSeriesIndexInNewAPI( -1 )
493 , m_nPointIndex( -1 )
494 , m_bLinesAllowed(true)
497 //need initialize call afterwards
500 void SAL_CALL
DataSeriesPointWrapper::initialize( const uno::Sequence
< uno::Any
>& aArguments
)
501 throw ( uno::Exception
, uno::RuntimeException
, std::exception
)
503 OSL_PRECOND(aArguments
.getLength() >= 1,"need at least 1 argument to initialize the DataSeriesPointWrapper: series reference + optional datapoint index");
505 m_nSeriesIndexInNewAPI
= -1;//ignored in this case
507 if( aArguments
.getLength() >= 1 )
509 aArguments
[0] >>= m_xDataSeries
;
510 if( aArguments
.getLength() >= 2 )
511 aArguments
[1] >>= m_nPointIndex
;
514 if( !m_xDataSeries
.is() )
515 throw uno::Exception(
516 "DataSeries index invalid", static_cast< ::cppu::OWeakObject
* >( this ));
518 //todo: check upper border of point index
520 if( m_nPointIndex
>= 0 )
521 m_eType
= DATA_POINT
;
523 m_eType
= DATA_SERIES
;
526 DataSeriesPointWrapper::DataSeriesPointWrapper( eType _eType
,
527 sal_Int32 nSeriesIndexInNewAPI
,
528 sal_Int32 nPointIndex
, //ignored for series
529 ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
530 : m_spChart2ModelContact( spChart2ModelContact
)
531 , m_aEventListenerContainer( m_aMutex
)
533 , m_nSeriesIndexInNewAPI( nSeriesIndexInNewAPI
)
534 , m_nPointIndex( (_eType
== DATA_POINT
) ? nPointIndex
: -1 )
535 , m_bLinesAllowed( false )
540 DataSeriesPointWrapper::~DataSeriesPointWrapper()
544 // ____ XComponent ____
545 void SAL_CALL
DataSeriesPointWrapper::dispose()
546 throw (uno::RuntimeException
, std::exception
)
548 uno::Reference
< uno::XInterface
> xSource( static_cast< ::cppu::OWeakObject
* >( this ) );
549 m_aEventListenerContainer
.disposeAndClear( lang::EventObject( xSource
) );
551 m_xDataSeries
.clear();
552 clearWrappedPropertySet();
555 void SAL_CALL
DataSeriesPointWrapper::addEventListener(
556 const uno::Reference
< lang::XEventListener
>& xListener
)
557 throw (uno::RuntimeException
, std::exception
)
559 m_aEventListenerContainer
.addInterface( xListener
);
562 void SAL_CALL
DataSeriesPointWrapper::removeEventListener(
563 const uno::Reference
< lang::XEventListener
>& aListener
)
564 throw (uno::RuntimeException
, std::exception
)
566 m_aEventListenerContainer
.removeInterface( aListener
);
569 // ____ XEventListener ____
570 void SAL_CALL
DataSeriesPointWrapper::disposing( const lang::EventObject
& /*Source*/ )
571 throw (uno::RuntimeException
, std::exception
)
575 bool DataSeriesPointWrapper::isSupportingAreaProperties()
577 Reference
< chart2::XDataSeries
> xSeries( this->getDataSeries() );
578 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
579 Reference
< chart2::XChartType
> xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram
, xSeries
) );
580 sal_Int32 nDimensionCount
= DiagramHelper::getDimension( xDiagram
);
582 return ChartTypeHelper::isSupportingAreaProperties( xChartType
, nDimensionCount
);
585 Reference
< chart2::XDataSeries
> DataSeriesPointWrapper::getDataSeries()
587 Reference
< chart2::XDataSeries
> xSeries( m_xDataSeries
);
590 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
591 ::std::vector
< uno::Reference
< chart2::XDataSeries
> > aSeriesList(
592 ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
594 if( m_nSeriesIndexInNewAPI
>= 0 && m_nSeriesIndexInNewAPI
< static_cast<sal_Int32
>(aSeriesList
.size()) )
595 xSeries
= aSeriesList
[m_nSeriesIndexInNewAPI
];
601 Reference
< beans::XPropertySet
> DataSeriesPointWrapper::getDataPointProperties()
603 Reference
< beans::XPropertySet
> xPointProp
;
605 Reference
< chart2::XDataSeries
> xSeries( this->getDataSeries() );
607 // may throw an IllegalArgumentException
609 xPointProp
= xSeries
->getDataPointByIndex( m_nPointIndex
);
614 //ReferenceSizePropertyProvider
615 void DataSeriesPointWrapper::updateReferenceSize()
617 Reference
< beans::XPropertySet
> xProp( this->getInnerPropertySet(), uno::UNO_QUERY
);
620 if( xProp
->getPropertyValue("ReferencePageSize").hasValue() )
621 xProp
->setPropertyValue("ReferencePageSize", uno::makeAny(
622 m_spChart2ModelContact
->GetPageSize() ));
625 Any
DataSeriesPointWrapper::getReferenceSize()
628 Reference
< beans::XPropertySet
> xProp( this->getInnerPropertySet(), uno::UNO_QUERY
);
630 aRet
= xProp
->getPropertyValue("ReferencePageSize");
633 awt::Size
DataSeriesPointWrapper::getCurrentSizeForReference()
635 return m_spChart2ModelContact
->GetPageSize();
638 // WrappedPropertySet
641 beans::PropertyState SAL_CALL
DataSeriesPointWrapper::getPropertyState( const OUString
& rPropertyName
)
642 throw (beans::UnknownPropertyException
, uno::RuntimeException
, std::exception
)
644 beans::PropertyState
aState( beans::PropertyState_DIRECT_VALUE
);
647 if (rPropertyName
== "SymbolBitmapURL")
649 uno::Any aAny
= WrappedPropertySet::getPropertyValue("SymbolType");
650 sal_Int32 nVal
= com::sun::star::chart::ChartSymbolType::NONE
;
653 if (nVal
!= com::sun::star::chart::ChartSymbolType::BITMAPURL
)
654 return beans::PropertyState::PropertyState_DEFAULT_VALUE
;
658 if( m_eType
== DATA_SERIES
)
659 aState
= WrappedPropertySet::getPropertyState( rPropertyName
);
662 if( rPropertyName
== "FillColor")
664 Reference
< beans::XPropertySet
> xSeriesProp( getDataSeries(), uno::UNO_QUERY
);
665 bool bVaryColorsByPoint
= false;
666 if( xSeriesProp
.is() && (xSeriesProp
->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint
)
667 && bVaryColorsByPoint
)
668 return beans::PropertyState_DIRECT_VALUE
;
670 else if( rPropertyName
== "Lines"
671 || rPropertyName
== "SymbolType"
672 || rPropertyName
== "SymbolSize" )
673 return WrappedPropertySet::getPropertyState( rPropertyName
);
675 uno::Any
aDefault( getPropertyDefault( rPropertyName
) );
676 uno::Any
aValue( getPropertyValue( rPropertyName
) );
677 if( aDefault
==aValue
)
678 aState
= beans::PropertyState_DEFAULT_VALUE
;
681 catch( const beans::UnknownPropertyException
& )
685 catch( const uno::RuntimeException
& )
689 catch( const lang::WrappedTargetException
& e
)
691 css::uno::Any
a(e
.TargetException
);
692 throw css::lang::WrappedTargetRuntimeException(
693 "wrapped Exception " + e
.Message
,
694 css::uno::Reference
<css::uno::XInterface
>(), a
);
696 catch( const uno::Exception
& e
)
698 css::uno::Any
a(cppu::getCaughtException());
699 throw css::lang::WrappedTargetRuntimeException(
700 "wrapped Exception " + e
.Message
,
701 css::uno::Reference
<css::uno::XInterface
>(), a
);
706 void SAL_CALL
DataSeriesPointWrapper::setPropertyToDefault( const OUString
& rPropertyName
)
707 throw (beans::UnknownPropertyException
, uno::RuntimeException
, std::exception
)
709 if( m_eType
== DATA_SERIES
)
710 WrappedPropertySet::setPropertyToDefault( rPropertyName
);
713 //for data points the default is given by the series
714 setPropertyValue( rPropertyName
, getPropertyDefault( rPropertyName
) );
717 Any SAL_CALL
DataSeriesPointWrapper::getPropertyDefault( const OUString
& rPropertyName
)
718 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
723 sal_Int32 nHandle
= getInfoHelper().getHandleByName( rPropertyName
);
726 //always take the series current value as default for points
727 Reference
< beans::XPropertySet
> xInnerPropertySet( getDataSeries(), uno::UNO_QUERY
);
728 if( xInnerPropertySet
.is() )
730 const WrappedProperty
* pWrappedProperty
= getWrappedProperty( rPropertyName
);
731 if( pWrappedProperty
)
732 aRet
= pWrappedProperty
->getPropertyValue(xInnerPropertySet
);
734 aRet
= xInnerPropertySet
->getPropertyValue( rPropertyName
);
738 catch( const beans::UnknownPropertyException
& )
740 aRet
= WrappedPropertySet::getPropertyDefault( rPropertyName
);
745 Reference
< beans::XPropertySet
> DataSeriesPointWrapper::getInnerPropertySet()
747 if( m_eType
== DATA_SERIES
)
748 return Reference
< beans::XPropertySet
>( getDataSeries(), uno::UNO_QUERY
);
749 return getDataPointProperties();
752 const Sequence
< beans::Property
>& DataSeriesPointWrapper::getPropertySequence()
754 if( m_eType
== DATA_SERIES
)
755 return *StaticSeriesWrapperPropertyArray::get();
757 return *StaticPointWrapperPropertyArray::get();
760 const std::vector
< WrappedProperty
* > DataSeriesPointWrapper::createWrappedProperties()
762 ::std::vector
< ::chart::WrappedProperty
* > aWrappedProperties
;
764 WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties
, this );
766 if( m_eType
== DATA_SERIES
)
768 WrappedStatisticProperties::addWrappedPropertiesForSeries( aWrappedProperties
, m_spChart2ModelContact
);
769 aWrappedProperties
.push_back( new WrappedAttachedAxisProperty( m_spChart2ModelContact
) );
771 aWrappedProperties
.push_back( new WrappedNumberFormatProperty(m_spChart2ModelContact
) );
772 aWrappedProperties
.push_back( new WrappedLinkNumberFormatProperty(m_spChart2ModelContact
) );
775 WrappedSymbolProperties::addWrappedPropertiesForSeries( aWrappedProperties
, m_spChart2ModelContact
);
776 WrappedDataCaptionProperties::addWrappedPropertiesForSeries( aWrappedProperties
, m_spChart2ModelContact
);
777 WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties
, m_spChart2ModelContact
);
779 //add unnamed line properties (different inner names here)
781 aWrappedProperties
.push_back( new WrappedProperty("FillColor","Color") );
782 aWrappedProperties
.push_back( new WrappedLineStyleProperty( this ) );
783 aWrappedProperties
.push_back( new WrappedLineColorProperty( this ) );
784 aWrappedProperties
.push_back( new WrappedSeriesAreaOrLineProperty("LineDashName","BorderDashName","LineDashName", this ) );
785 aWrappedProperties
.push_back( new WrappedSeriesAreaOrLineProperty("LineTransparence","BorderTransparency","Transparency", this ) );
786 aWrappedProperties
.push_back( new WrappedSeriesAreaOrLineProperty("LineWidth","BorderWidth","LineWidth", this ) );
787 aWrappedProperties
.push_back( new WrappedProperty("FillStyle","FillStyle" ) );
788 aWrappedProperties
.push_back( new WrappedProperty("FillTransparence","Transparency") );
790 aWrappedProperties
.push_back( new WrappedIgnoreProperty("LineJoint", uno::makeAny( drawing::LineJoint_ROUND
) ) );
791 aWrappedProperties
.push_back( new WrappedProperty("FillTransparenceGradientName","TransparencyGradientName") );
792 aWrappedProperties
.push_back( new WrappedProperty("FillGradientName","GradientName") );
793 aWrappedProperties
.push_back( new WrappedProperty("FillGradientStepCount","GradientStepCount") );
794 aWrappedProperties
.push_back( new WrappedProperty("FillHatchName","HatchName") );
795 aWrappedProperties
.push_back( new WrappedProperty("FillBitmapName","FillBitmapName") );
796 aWrappedProperties
.push_back( new WrappedProperty("FillBackground","FillBackground") );
799 aWrappedProperties
.push_back( new WrappedProperty("FillBitmapMode","FillBitmapMode") );
800 aWrappedProperties
.push_back( new WrappedProperty("FillBitmapSizeX","FillBitmapSizeX") );
801 aWrappedProperties
.push_back( new WrappedProperty("FillBitmapSizeY","FillBitmapSizeY") );
802 aWrappedProperties
.push_back( new WrappedProperty("FillBitmapLogicalSize","FillBitmapLogicalSize") );
803 aWrappedProperties
.push_back( new WrappedProperty("FillBitmapOffsetX","FillBitmapOffsetX") );
804 aWrappedProperties
.push_back( new WrappedProperty("FillBitmapOffsetY","FillBitmapOffsetY") );
805 aWrappedProperties
.push_back( new WrappedProperty("FillBitmapRectanglePoint","FillBitmapRectanglePoint") );
806 aWrappedProperties
.push_back( new WrappedProperty("FillBitmapPositionOffsetX","FillBitmapPositionOffsetX") );
807 aWrappedProperties
.push_back( new WrappedProperty("FillBitmapPositionOffsetY","FillBitmapPositionOffsetY") );
809 aWrappedProperties
.push_back( new WrappedProperty("SolidType","Geometry3D") );
810 aWrappedProperties
.push_back( new WrappedSegmentOffsetProperty() );
811 aWrappedProperties
.push_back( new WrappedProperty("D3DPercentDiagonal","PercentDiagonal") );
813 aWrappedProperties
.push_back( new WrappedTextRotationProperty() );
815 return aWrappedProperties
;
818 void SAL_CALL
DataSeriesPointWrapper::setPropertyValue( const OUString
& rPropertyName
, const Any
& rValue
)
819 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
821 if(rPropertyName
== "Lines")
823 if( ! (rValue
>>= m_bLinesAllowed
) )
824 throw lang::IllegalArgumentException("Property Lines requires value of type sal_Bool", 0, 0 );
827 sal_Int32 nHandle
= getInfoHelper().getHandleByName( rPropertyName
);
828 static const sal_Int32 nErrorCategoryHandle
= getInfoHelper().getHandleByName("ErrorCategory");
829 if( nErrorCategoryHandle
== nHandle
)
831 ::com::sun::star::chart::ChartErrorCategory aNewValue
= ::com::sun::star::chart::ChartErrorCategory_NONE
;
832 rValue
>>= aNewValue
;
834 bool bSetHighAndLowValues
= false;
837 case ::com::sun::star::chart::ChartErrorCategory_CONSTANT_VALUE
:
838 aHigh
= this->getPropertyValue("ConstantErrorHigh");
839 aLow
= this->getPropertyValue("ConstantErrorLow");
840 bSetHighAndLowValues
= true;
842 case ::com::sun::star::chart::ChartErrorCategory_PERCENT
:
843 aHigh
= aLow
= this->getPropertyValue("PercentageError");
844 bSetHighAndLowValues
= true;
846 case ::com::sun::star::chart::ChartErrorCategory_ERROR_MARGIN
:
847 aHigh
= aLow
= this->getPropertyValue("ErrorMargin");
848 bSetHighAndLowValues
= true;
854 WrappedPropertySet::setPropertyValue( rPropertyName
, rValue
);
856 if(bSetHighAndLowValues
)
860 case ::com::sun::star::chart::ChartErrorCategory_CONSTANT_VALUE
:
861 this->setPropertyValue("ConstantErrorHigh",aHigh
);
862 this->setPropertyValue("ConstantErrorLow",aLow
);
864 case ::com::sun::star::chart::ChartErrorCategory_PERCENT
:
865 this->setPropertyValue("PercentageError",aHigh
);
867 case ::com::sun::star::chart::ChartErrorCategory_ERROR_MARGIN
:
868 this->setPropertyValue("ErrorMargin",aHigh
);
876 WrappedPropertySet::setPropertyValue( rPropertyName
, rValue
);
879 Any SAL_CALL
DataSeriesPointWrapper::getPropertyValue( const OUString
& rPropertyName
)
880 throw ( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
882 if( m_eType
== DATA_POINT
)
884 if( rPropertyName
== "FillColor" )
886 Reference
< beans::XPropertySet
> xSeriesProp( getDataSeries(), uno::UNO_QUERY
);
887 bool bVaryColorsByPoint
= false;
888 if( xSeriesProp
.is() && (xSeriesProp
->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint
)
889 && bVaryColorsByPoint
)
891 uno::Reference
< beans::XPropertyState
> xPointState( DataSeriesPointWrapper::getDataPointProperties(), uno::UNO_QUERY
);
892 if( xPointState
.is() && xPointState
->getPropertyState("Color") == beans::PropertyState_DEFAULT_VALUE
)
894 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
897 Reference
< chart2::XColorScheme
> xColorScheme( xDiagram
->getDefaultColorScheme() );
898 if( xColorScheme
.is() )
899 return uno::makeAny( xColorScheme
->getColorByIndex( m_nPointIndex
) );
905 return WrappedPropertySet::getPropertyValue( rPropertyName
);
908 uno::Sequence
< OUString
> DataSeriesPointWrapper::getSupportedServiceNames_Static()
910 uno::Sequence
< OUString
> aServices( 7 );
911 aServices
[ 0 ] = "com.sun.star.chart.ChartDataRowProperties";
912 aServices
[ 1 ] = "com.sun.star.chart.ChartDataPointProperties";
913 aServices
[ 2 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
914 aServices
[ 3 ] = "com.sun.star.beans.PropertySet";
915 aServices
[ 4 ] = "com.sun.star.drawing.FillProperties";
916 aServices
[ 5 ] = "com.sun.star.drawing.LineProperties";
917 aServices
[ 6 ] = "com.sun.star.style.CharacterProperties";
922 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
923 OUString SAL_CALL
DataSeriesPointWrapper::getImplementationName()
924 throw( css::uno::RuntimeException
, std::exception
)
926 return getImplementationName_Static();
929 OUString
DataSeriesPointWrapper::getImplementationName_Static()
931 return OUString(lcl_aServiceName
);
934 sal_Bool SAL_CALL
DataSeriesPointWrapper::supportsService( const OUString
& rServiceName
)
935 throw( css::uno::RuntimeException
, std::exception
)
937 return cppu::supportsService(this, rServiceName
);
940 css::uno::Sequence
< OUString
> SAL_CALL
DataSeriesPointWrapper::getSupportedServiceNames()
941 throw( css::uno::RuntimeException
, std::exception
)
943 return getSupportedServiceNames_Static();
946 } // namespace wrapper
949 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */