1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DataSeriesPointWrapper.cxx,v $
10 * $Revision: 1.15.44.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "DataSeriesPointWrapper.hxx"
35 #include "RegressionCurveHelper.hxx"
36 #include "Chart2ModelContact.hxx"
37 #include "ChartTypeHelper.hxx"
38 #include "DiagramHelper.hxx"
39 #include "ContainerHelper.hxx"
40 #include "ChartModelHelper.hxx"
41 #include "LineProperties.hxx"
42 #include "FillProperties.hxx"
43 #include "CharacterProperties.hxx"
44 #include "UserDefinedProperties.hxx"
45 #include "WrappedCharacterHeightProperty.hxx"
46 #include "WrappedProperty.hxx"
47 #include "WrappedIgnoreProperty.hxx"
48 #include "WrappedStatisticProperties.hxx"
49 #include "WrappedSymbolProperties.hxx"
50 #include "WrappedDataCaptionProperties.hxx"
51 #include "WrappedSeriesAreaOrLineProperty.hxx"
52 #include "WrappedScaleTextProperties.hxx"
53 #include "WrappedNumberFormatProperty.hxx"
54 #include "WrappedTextRotationProperty.hxx"
55 #include <rtl/ustrbuf.hxx>
56 #include <rtl/math.hxx>
57 // header for define DBG_ASSERT
58 #include <tools/debug.hxx>
61 #include <comphelper/InlineContainer.hxx>
62 #include <com/sun/star/beans/PropertyAttribute.hpp>
63 #include <com/sun/star/chart/ChartAxisAssign.hpp>
64 #include <com/sun/star/chart/ChartErrorCategory.hpp>
65 #include <com/sun/star/chart/XChartDocument.hpp>
66 #include <com/sun/star/drawing/FillStyle.hpp>
67 #include <com/sun/star/drawing/LineJoint.hpp>
68 #include <com/sun/star/drawing/LineStyle.hpp>
70 using namespace ::com::sun::star
;
71 using namespace ::chart::wrapper
;
73 using ::com::sun::star::uno::Reference
;
74 using ::com::sun::star::uno::Sequence
;
75 using ::com::sun::star::beans::Property
;
76 using ::com::sun::star::uno::Any
;
77 using ::osl::MutexGuard
;
81 static const ::rtl::OUString
lcl_aServiceName(
82 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.DataSeries" ));
86 //data point properties
87 PROP_SERIES_DATAPOINT_SOLIDTYPE
,
88 PROP_SERIES_DATAPOINT_SEGMENT_OFFSET
,
89 PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL
,
90 PROP_SERIES_DATAPOINT_LABEL_SEPARATOR
,
91 PROP_SERIES_NUMBERFORMAT
,
92 PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE
,
93 PROP_SERIES_PERCENTAGE_NUMBERFORMAT
,
94 PROP_SERIES_DATAPOINT_LABEL_PLACEMENT
,
95 //other series properties
96 PROP_SERIES_ATTACHED_AXIS
,
97 PROP_SERIES_DATAPOINT_TEXT_ROTATION
100 void lcl_AddPropertiesToVector_PointProperties(
101 ::std::vector
< Property
> & rOutProperties
)
103 //service chart::Chart3DBarProperties
104 rOutProperties
.push_back(
105 Property( C2U( "SolidType" ),
106 PROP_SERIES_DATAPOINT_SOLIDTYPE
,
107 ::getCppuType( reinterpret_cast< sal_Int32
* >(0)),
108 beans::PropertyAttribute::BOUND
109 | beans::PropertyAttribute::MAYBEDEFAULT
));
111 rOutProperties
.push_back(
112 Property( C2U( "SegmentOffset" ),
113 PROP_SERIES_DATAPOINT_SEGMENT_OFFSET
,
114 ::getCppuType( reinterpret_cast< sal_Int32
* >(0)),
115 beans::PropertyAttribute::BOUND
116 | beans::PropertyAttribute::MAYBEDEFAULT
));
118 rOutProperties
.push_back(
119 Property( C2U( "D3DPercentDiagonal" ),
120 PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL
,
121 ::getCppuType( reinterpret_cast< sal_Int16
* >(0)),
122 beans::PropertyAttribute::BOUND
123 | beans::PropertyAttribute::MAYBEVOID
));
125 rOutProperties
.push_back(
126 Property( C2U( "LabelSeparator" ),
127 PROP_SERIES_DATAPOINT_LABEL_SEPARATOR
,
128 ::getCppuType( reinterpret_cast< const ::rtl::OUString
* >(0)),
129 beans::PropertyAttribute::BOUND
130 | beans::PropertyAttribute::MAYBEDEFAULT
));
132 rOutProperties
.push_back(
133 Property( C2U( "NumberFormat" ),
134 PROP_SERIES_NUMBERFORMAT
,
135 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
136 beans::PropertyAttribute::BOUND
137 | beans::PropertyAttribute::MAYBEVOID
));
139 rOutProperties
.push_back(
140 Property( C2U( "PercentageNumberFormat" ),
141 PROP_SERIES_PERCENTAGE_NUMBERFORMAT
,
142 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
143 beans::PropertyAttribute::BOUND
144 | beans::PropertyAttribute::MAYBEVOID
));
146 rOutProperties
.push_back(
147 Property( C2U( "LabelPlacement" ),
148 PROP_SERIES_DATAPOINT_LABEL_PLACEMENT
,
149 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
150 beans::PropertyAttribute::BOUND
151 | beans::PropertyAttribute::MAYBEVOID
));
153 rOutProperties
.push_back(
154 Property( C2U( "TextRotation" ),
155 PROP_SERIES_DATAPOINT_TEXT_ROTATION
,
156 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
157 beans::PropertyAttribute::BOUND
158 | beans::PropertyAttribute::MAYBEDEFAULT
));
161 void lcl_AddPropertiesToVector_SeriesOnly(
162 ::std::vector
< Property
> & rOutProperties
)
164 rOutProperties
.push_back(
165 Property( C2U( "Axis" ),
166 PROP_SERIES_ATTACHED_AXIS
,
167 ::getCppuType( reinterpret_cast< sal_Int32
* >(0)),
168 beans::PropertyAttribute::BOUND
169 | beans::PropertyAttribute::MAYBEDEFAULT
));
171 rOutProperties
.push_back(
172 Property( C2U( "LinkNumberFormatToSource" ),
173 PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE
,
174 ::getBooleanCppuType(),
175 beans::PropertyAttribute::BOUND
176 | beans::PropertyAttribute::MAYBEDEFAULT
));
179 const uno::Sequence
< Property
> & lcl_GetPropertySequence( DataSeriesPointWrapper::eType _eType
)
181 static uno::Sequence
< Property
> aSeriesPropSeq
;
182 static uno::Sequence
< Property
> aPointPropSeq
;
185 MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
186 uno::Sequence
< Property
>& rPropSeq
=
187 (_eType
== DataSeriesPointWrapper::DATA_SERIES
) ? aSeriesPropSeq
: aPointPropSeq
;
188 if( 0 == rPropSeq
.getLength() )
191 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
193 lcl_AddPropertiesToVector_PointProperties( aProperties
);
194 if( _eType
== DataSeriesPointWrapper::DATA_SERIES
)
196 lcl_AddPropertiesToVector_SeriesOnly( aProperties
);
197 WrappedStatisticProperties::addProperties( aProperties
);
199 WrappedSymbolProperties::addProperties( aProperties
); //for series and points
200 WrappedDataCaptionProperties::addProperties( aProperties
); //for series and points
202 ::chart::FillProperties::AddPropertiesToVector( aProperties
);
203 ::chart::LineProperties::AddPropertiesToVector( aProperties
);
204 ::chart::CharacterProperties::AddPropertiesToVector( aProperties
);
205 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
206 ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties
);
208 // and sort them for access via bsearch
209 ::std::sort( aProperties
.begin(), aProperties
.end(), ::chart::PropertyNameLess() );
211 // transfer result to static Sequence
212 rPropSeq
= ::chart::ContainerHelper::ContainerToSequence( aProperties
);
218 //----------------------------------------------------------------------------------------------------------------------
219 //----------------------------------------------------------------------------------------------------------------------
220 //----------------------------------------------------------------------------------------------------------------------
222 //PROP_SERIES_ATTACHED_AXIS
223 class WrappedAttachedAxisProperty
: public ::chart::WrappedProperty
226 WrappedAttachedAxisProperty( ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
);
227 virtual ~WrappedAttachedAxisProperty();
229 virtual void setPropertyValue( const Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
230 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
);
232 virtual Any
getPropertyValue( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
233 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
235 virtual Any
getPropertyDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
236 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
239 ::boost::shared_ptr
< Chart2ModelContact
> m_spChart2ModelContact
;
242 WrappedAttachedAxisProperty::WrappedAttachedAxisProperty(
243 ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
244 : WrappedProperty(C2U("Axis"),rtl::OUString())
245 , m_spChart2ModelContact( spChart2ModelContact
)
249 WrappedAttachedAxisProperty::~WrappedAttachedAxisProperty()
253 Any
WrappedAttachedAxisProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
254 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
257 aRet
<<= ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y
;
261 Any
WrappedAttachedAxisProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
262 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
266 uno::Reference
< chart2::XDataSeries
> xDataSeries( xInnerPropertySet
, uno::UNO_QUERY
);
267 bool bAttachedToMainAxis
= ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries
);
268 if( bAttachedToMainAxis
)
269 aRet
<<= ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y
;
271 aRet
<<= ::com::sun::star::chart::ChartAxisAssign::SECONDARY_Y
;
275 void WrappedAttachedAxisProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
276 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
278 uno::Reference
< chart2::XDataSeries
> xDataSeries( xInnerPropertySet
, uno::UNO_QUERY
);
280 sal_Int32 nChartAxisAssign
= ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y
;
281 if( ! (rOuterValue
>>= nChartAxisAssign
) )
282 throw lang::IllegalArgumentException( C2U("Property Axis requires value of type sal_Int32"), 0, 0 );
284 bool bNewAttachedToMainAxis
= nChartAxisAssign
== ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y
;
285 bool bOldAttachedToMainAxis
= ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries
);
287 if( bNewAttachedToMainAxis
!= bOldAttachedToMainAxis
)
289 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
291 ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis
, xDataSeries
, xDiagram
, m_spChart2ModelContact
->m_xContext
);
295 //----------------------------------------------------------------------------------------------------------------------
297 class WrappedSegmentOffsetProperty
: public ::chart::WrappedProperty
300 WrappedSegmentOffsetProperty();
301 virtual ~WrappedSegmentOffsetProperty();
304 virtual Any
convertInnerToOuterValue( const Any
& rInnerValue
) const;
305 virtual Any
convertOuterToInnerValue( const Any
& rOuterValue
) const;
308 WrappedSegmentOffsetProperty::WrappedSegmentOffsetProperty() :
309 WrappedProperty( C2U( "SegmentOffset" ), C2U( "Offset" ) )
312 WrappedSegmentOffsetProperty::~WrappedSegmentOffsetProperty()
315 Any
WrappedSegmentOffsetProperty::convertInnerToOuterValue( const Any
& rInnerValue
) const
317 // convert new double offset to former integer segment-offset
319 Any
aResult( rInnerValue
);
321 if( rInnerValue
>>= fOffset
)
322 aResult
<<= static_cast< sal_Int32
>( ::rtl::math::round( fOffset
* 100.0 ));
327 Any
WrappedSegmentOffsetProperty::convertOuterToInnerValue( const Any
& rOuterValue
) const
329 // convert former integer segment-offset to new double offset
330 sal_Int32 nOffset
= 0;
331 Any
aResult( rOuterValue
);
333 if( rOuterValue
>>= nOffset
)
334 aResult
<<= (static_cast< double >( nOffset
) / 100.0);
339 //----------------------------------------------------------------------------------------------------------------------
341 class WrappedLineColorProperty
: public WrappedSeriesAreaOrLineProperty
344 WrappedLineColorProperty( DataSeriesPointWrapper
* pDataSeriesPointWrapper
);
345 virtual ~WrappedLineColorProperty();
347 virtual void setPropertyValue( const Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
348 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
);
350 virtual void setPropertyToDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
351 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
353 virtual ::com::sun::star::uno::Any
getPropertyDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
354 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
357 DataSeriesPointWrapper
* m_pDataSeriesPointWrapper
;
358 mutable Any m_aDefaultValue
;
359 mutable Any m_aOuterValue
;
362 WrappedLineColorProperty::WrappedLineColorProperty(
363 DataSeriesPointWrapper
* pDataSeriesPointWrapper
)
364 : WrappedSeriesAreaOrLineProperty(C2U( "LineColor" ), C2U( "BorderColor" ), C2U( "Color" ), pDataSeriesPointWrapper
)
365 , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper
)
366 , m_aDefaultValue(uno::makeAny(sal_Int32( 0x0099ccff ))) // blue 8
367 , m_aOuterValue(m_aDefaultValue
)
371 WrappedLineColorProperty::~WrappedLineColorProperty()
375 void WrappedLineColorProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
376 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
378 if( m_pDataSeriesPointWrapper
&& m_pDataSeriesPointWrapper
->isLinesForbidden() )
379 m_aOuterValue
= rOuterValue
;
381 WrappedSeriesAreaOrLineProperty::setPropertyValue( rOuterValue
, xInnerPropertySet
);
384 void WrappedLineColorProperty::setPropertyToDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
385 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
)
387 if( m_pDataSeriesPointWrapper
&& m_pDataSeriesPointWrapper
->isLinesForbidden() )
388 m_aOuterValue
= m_aDefaultValue
;
390 WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState
);
393 Any
WrappedLineColorProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
394 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
396 if( m_pDataSeriesPointWrapper
&& !m_pDataSeriesPointWrapper
->isSupportingAreaProperties() )
397 return m_aDefaultValue
;
399 return WrappedSeriesAreaOrLineProperty::getPropertyDefault( xInnerPropertyState
);
402 //----------------------------------------------------------------------------------------------------------------------
404 class WrappedLineStyleProperty
: public WrappedSeriesAreaOrLineProperty
407 WrappedLineStyleProperty( DataSeriesPointWrapper
* pDataSeriesPointWrapper
);
408 virtual ~WrappedLineStyleProperty();
410 virtual void setPropertyValue( const Any
& rOuterValue
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xInnerPropertySet
) const
411 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
);
413 virtual void setPropertyToDefault( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>& xInnerPropertyState
) const
414 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
);
417 DataSeriesPointWrapper
* m_pDataSeriesPointWrapper
;
418 mutable Any m_aDefaultValue
;
419 mutable Any m_aOuterValue
;
422 WrappedLineStyleProperty::WrappedLineStyleProperty(
423 DataSeriesPointWrapper
* pDataSeriesPointWrapper
)
424 : WrappedSeriesAreaOrLineProperty(C2U( "LineStyle" ), C2U( "BorderStyle" ), C2U( "LineStyle" ), pDataSeriesPointWrapper
)
425 , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper
)
426 , m_aDefaultValue(uno::makeAny(drawing::LineStyle_SOLID
))
427 , m_aOuterValue(m_aDefaultValue
)
431 WrappedLineStyleProperty::~WrappedLineStyleProperty()
435 void WrappedLineStyleProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
436 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
438 Any
aNewValue(rOuterValue
);
439 if( m_pDataSeriesPointWrapper
&& m_pDataSeriesPointWrapper
->isLinesForbidden() )
441 m_aOuterValue
= rOuterValue
;
442 aNewValue
= uno::makeAny(drawing::LineStyle_NONE
);
444 WrappedSeriesAreaOrLineProperty::setPropertyValue( aNewValue
, xInnerPropertySet
);
447 void WrappedLineStyleProperty::setPropertyToDefault( const Reference
< beans::XPropertyState
>& xInnerPropertyState
) const
448 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
)
450 if( m_pDataSeriesPointWrapper
&& m_pDataSeriesPointWrapper
->isLinesForbidden() )
451 m_aOuterValue
= m_aDefaultValue
;
453 WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState
);
456 //----------------------------------------------------------------------------------------------------------------------
457 //----------------------------------------------------------------------------------------------------------------------
458 //----------------------------------------------------------------------------------------------------------------------
460 } // anonymous namespace
462 // --------------------------------------------------------------------------------
469 DataSeriesPointWrapper::DataSeriesPointWrapper(
470 ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
471 : m_spChart2ModelContact( spChart2ModelContact
)
472 , m_aEventListenerContainer( m_aMutex
)
473 , m_eType( DATA_SERIES
)
474 , m_nSeriesIndexInNewAPI( -1 )
475 , m_nPointIndex( -1 )
476 , m_bLinesAllowed(sal_True
)
479 //need initialize call afterwards
482 void SAL_CALL
DataSeriesPointWrapper::initialize( const uno::Sequence
< uno::Any
>& aArguments
)
483 throw ( uno::Exception
, uno::RuntimeException
)
485 DBG_ASSERT(aArguments
.getLength() >= 1,"need at least 1 argument to initialize the DataSeriesPointWrapper: series reference + optional datapoint index");
487 m_nSeriesIndexInNewAPI
= -1;//ignored in this case
489 if( aArguments
.getLength() >= 1 )
491 aArguments
[0] >>= m_xDataSeries
;
492 if( aArguments
.getLength() >= 2 )
493 aArguments
[1] >>= m_nPointIndex
;
496 if( !m_xDataSeries
.is() )
497 throw uno::Exception(
498 C2U( "DataSeries index invalid" ), static_cast< ::cppu::OWeakObject
* >( this ));
500 //todo: check upper border of point index
502 if( m_nPointIndex
>= 0 )
503 m_eType
= DATA_POINT
;
505 m_eType
= DATA_SERIES
;
508 DataSeriesPointWrapper::DataSeriesPointWrapper( eType _eType
509 , sal_Int32 nSeriesIndexInNewAPI
510 , sal_Int32 nPointIndex
//ignored for series
511 , ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
)
512 : m_spChart2ModelContact( spChart2ModelContact
)
513 , m_aEventListenerContainer( m_aMutex
)
515 , m_nSeriesIndexInNewAPI( nSeriesIndexInNewAPI
)
516 , m_nPointIndex( (_eType
== DATA_POINT
) ? nPointIndex
: -1 )
521 DataSeriesPointWrapper::~DataSeriesPointWrapper()
525 // ____ XComponent ____
526 void SAL_CALL
DataSeriesPointWrapper::dispose()
527 throw (uno::RuntimeException
)
529 uno::Reference
< uno::XInterface
> xSource( static_cast< ::cppu::OWeakObject
* >( this ) );
530 m_aEventListenerContainer
.disposeAndClear( lang::EventObject( xSource
) );
532 m_xDataSeries
.clear();
533 clearWrappedPropertySet();
536 void SAL_CALL
DataSeriesPointWrapper::addEventListener(
537 const uno::Reference
< lang::XEventListener
>& xListener
)
538 throw (uno::RuntimeException
)
540 m_aEventListenerContainer
.addInterface( xListener
);
543 void SAL_CALL
DataSeriesPointWrapper::removeEventListener(
544 const uno::Reference
< lang::XEventListener
>& aListener
)
545 throw (uno::RuntimeException
)
547 m_aEventListenerContainer
.removeInterface( aListener
);
550 // ____ XEventListener ____
551 void SAL_CALL
DataSeriesPointWrapper::disposing( const lang::EventObject
& /*Source*/ )
552 throw (uno::RuntimeException
)
556 // ================================================================================
558 bool DataSeriesPointWrapper::isSupportingAreaProperties()
560 Reference
< chart2::XDataSeries
> xSeries( this->getDataSeries() );
561 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
562 Reference
< chart2::XChartType
> xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram
, xSeries
) );
563 sal_Int32 nDimensionCount
= DiagramHelper::getDimension( xDiagram
);
565 return ChartTypeHelper::isSupportingAreaProperties( xChartType
, nDimensionCount
);
568 bool DataSeriesPointWrapper::isLinesForbidden()
570 return !m_bLinesAllowed
;
573 Reference
< chart2::XDataSeries
> DataSeriesPointWrapper::getDataSeries()
575 Reference
< chart2::XDataSeries
> xSeries( m_xDataSeries
);
578 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
579 ::std::vector
< uno::Reference
< chart2::XDataSeries
> > aSeriesList(
580 ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
582 if( m_nSeriesIndexInNewAPI
>= 0 && m_nSeriesIndexInNewAPI
< static_cast<sal_Int32
>(aSeriesList
.size()) )
583 xSeries
= aSeriesList
[m_nSeriesIndexInNewAPI
];
589 Reference
< beans::XPropertySet
> DataSeriesPointWrapper::getDataPointProperties()
591 Reference
< beans::XPropertySet
> xPointProp
;
593 Reference
< chart2::XDataSeries
> xSeries( this->getDataSeries() );
595 // may throw an IllegalArgumentException
597 xPointProp
= xSeries
->getDataPointByIndex( m_nPointIndex
);
602 // ================================================================================
604 //ReferenceSizePropertyProvider
605 void DataSeriesPointWrapper::updateReferenceSize()
607 Reference
< beans::XPropertySet
> xProp( this->getInnerPropertySet(), uno::UNO_QUERY
);
610 if( xProp
->getPropertyValue( C2U("ReferencePageSize") ).hasValue() )
611 xProp
->setPropertyValue( C2U("ReferencePageSize"), uno::makeAny(
612 m_spChart2ModelContact
->GetPageSize() ));
615 Any
DataSeriesPointWrapper::getReferenceSize()
618 Reference
< beans::XPropertySet
> xProp( this->getInnerPropertySet(), uno::UNO_QUERY
);
620 aRet
= xProp
->getPropertyValue( C2U("ReferencePageSize") );
623 awt::Size
DataSeriesPointWrapper::getCurrentSizeForReference()
625 return m_spChart2ModelContact
->GetPageSize();
628 // ================================================================================
630 // WrappedPropertySet
633 beans::PropertyState SAL_CALL
DataSeriesPointWrapper::getPropertyState( const ::rtl::OUString
& rPropertyName
)
634 throw (beans::UnknownPropertyException
, uno::RuntimeException
)
636 beans::PropertyState
aState( beans::PropertyState_DIRECT_VALUE
);
638 if( m_eType
== DATA_SERIES
)
639 aState
= WrappedPropertySet::getPropertyState( rPropertyName
);
642 if( rPropertyName
.equals(C2U("FillColor")) )
644 Reference
< beans::XPropertySet
> xSeriesProp( getDataSeries(), uno::UNO_QUERY
);
645 sal_Bool bVaryColorsByPoint
= sal_False
;
646 if( xSeriesProp
.is() && (xSeriesProp
->getPropertyValue( C2U("VaryColorsByPoint") ) >>= bVaryColorsByPoint
)
647 && bVaryColorsByPoint
)
648 return beans::PropertyState_DIRECT_VALUE
;
650 else if( rPropertyName
.equals(C2U("Lines"))
651 || rPropertyName
.equals(C2U("SymbolType"))
652 || rPropertyName
.equals(C2U("SymbolSize")) )
653 return WrappedPropertySet::getPropertyState( rPropertyName
);
655 uno::Any
aDefault( getPropertyDefault( rPropertyName
) );
656 uno::Any
aValue( getPropertyValue( rPropertyName
) );
657 if( aDefault
==aValue
)
658 aState
= beans::PropertyState_DEFAULT_VALUE
;
663 void SAL_CALL
DataSeriesPointWrapper::setPropertyToDefault( const ::rtl::OUString
& rPropertyName
)
664 throw (beans::UnknownPropertyException
, uno::RuntimeException
)
666 if( m_eType
== DATA_SERIES
)
667 WrappedPropertySet::setPropertyToDefault( rPropertyName
);
670 //for data points the default is given by the series
671 setPropertyValue( rPropertyName
, getPropertyDefault( rPropertyName
) );
674 Any SAL_CALL
DataSeriesPointWrapper::getPropertyDefault( const ::rtl::OUString
& rPropertyName
)
675 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
680 sal_Int32 nHandle
= getInfoHelper().getHandleByName( rPropertyName
);
683 //always take the series current value as default for points
684 Reference
< beans::XPropertySet
> xInnerPropertySet( getDataSeries(), uno::UNO_QUERY
);
685 if( xInnerPropertySet
.is() )
687 const WrappedProperty
* pWrappedProperty
= getWrappedProperty( rPropertyName
);
688 if( pWrappedProperty
)
689 aRet
= pWrappedProperty
->getPropertyValue(xInnerPropertySet
);
691 aRet
= xInnerPropertySet
->getPropertyValue( rPropertyName
);
695 catch( beans::UnknownPropertyException
& ex
)
698 aRet
= WrappedPropertySet::getPropertyDefault( rPropertyName
);
703 Reference
< beans::XPropertySet
> DataSeriesPointWrapper::getInnerPropertySet()
705 if( m_eType
== DATA_SERIES
)
706 return Reference
< beans::XPropertySet
>( getDataSeries(), uno::UNO_QUERY
);
707 return getDataPointProperties();
710 const Sequence
< beans::Property
>& DataSeriesPointWrapper::getPropertySequence()
712 return lcl_GetPropertySequence( m_eType
);
715 const std::vector
< WrappedProperty
* > DataSeriesPointWrapper::createWrappedProperties()
717 ::std::vector
< ::chart::WrappedProperty
* > aWrappedProperties
;
719 WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties
, this );
721 if( m_eType
== DATA_SERIES
)
723 WrappedStatisticProperties::addWrappedPropertiesForSeries( aWrappedProperties
, m_spChart2ModelContact
);
724 aWrappedProperties
.push_back( new WrappedAttachedAxisProperty( m_spChart2ModelContact
) );
726 WrappedNumberFormatProperty
* pWrappedNumberFormatProperty
= new WrappedNumberFormatProperty( m_spChart2ModelContact
);
727 aWrappedProperties
.push_back( pWrappedNumberFormatProperty
);
728 aWrappedProperties
.push_back( new WrappedLinkNumberFormatProperty(pWrappedNumberFormatProperty
) );
731 WrappedSymbolProperties::addWrappedPropertiesForSeries( aWrappedProperties
, m_spChart2ModelContact
);
732 WrappedDataCaptionProperties::addWrappedPropertiesForSeries( aWrappedProperties
, m_spChart2ModelContact
);
733 WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties
, m_spChart2ModelContact
);
735 //add unnamed fill properties (different inner names here)
736 // aWrappedProperties.push_back( new WrappedUnnamedProperty( C2U( "FillGradient" ), C2U( "GradientName" ) ) );
737 // aWrappedProperties.push_back( new WrappedUnnamedProperty( C2U( "FillHatch" ), C2U( "HatchName" ) ) );
738 // aWrappedProperties.push_back( new WrappedUnnamedProperty( C2U( "FillTransparenceGradient" ), C2U( "TransparencyGradientName" ) ) );
740 //add unnamed line properties (different inner names here)
741 // aWrappedProperties.push_back( new WrappedUnnamedProperty( C2U( "LineDash" ), C2U( "LineDashName" ) ) );
743 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillColor" ), C2U( "Color" ) ) );
744 aWrappedProperties
.push_back( new WrappedLineStyleProperty( this ) );
745 aWrappedProperties
.push_back( new WrappedLineColorProperty( this ) );
746 aWrappedProperties
.push_back( new WrappedSeriesAreaOrLineProperty( C2U( "LineDashName" ), C2U( "BorderDashName" ), C2U( "LineDashName" ), this ) );
747 aWrappedProperties
.push_back( new WrappedSeriesAreaOrLineProperty( C2U( "LineTransparence" ), C2U( "BorderTransparency" ), C2U( "Transparency" ), this ) );
748 aWrappedProperties
.push_back( new WrappedSeriesAreaOrLineProperty( C2U( "LineWidth" ), C2U( "BorderWidth" ), C2U( "LineWidth" ), this ) );
749 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillStyle" ), C2U( "FillStyle" ) ) );
750 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillTransparence" ), C2U( "Transparency" ) ) );
752 aWrappedProperties
.push_back( new WrappedIgnoreProperty( C2U( "LineJoint" ), uno::makeAny( drawing::LineJoint_NONE
) ) );
753 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillTransparenceGradientName" ), C2U( "TransparencyGradientName" ) ) );
754 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillGradientName" ), C2U( "GradientName" ) ) );
755 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillGradientStepCount" ), C2U( "GradientStepCount" ) ) );
756 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillHatchName" ), C2U( "HatchName" ) ) );
757 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBitmapName" ), C2U( "FillBitmapName" ) ) );
758 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBackground" ), C2U( "FillBackground" ) ) );
761 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBitmapMode" ), C2U( "FillBitmapMode" ) ) );
762 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBitmapSizeX" ), C2U( "FillBitmapSizeX" ) ) );
763 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBitmapSizeY" ), C2U( "FillBitmapSizeY" ) ) );
764 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBitmapLogicalSize" ), C2U( "FillBitmapLogicalSize" ) ) );
765 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBitmapOffsetX" ), C2U( "FillBitmapOffsetX" ) ) );
766 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBitmapOffsetY" ), C2U( "FillBitmapOffsetY" ) ) );
767 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBitmapRectanglePoint" ), C2U( "FillBitmapRectanglePoint" ) ) );
768 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBitmapPositionOffsetX" ), C2U( "FillBitmapPositionOffsetX" ) ) );
769 aWrappedProperties
.push_back( new WrappedProperty( C2U( "FillBitmapPositionOffsetY" ), C2U( "FillBitmapPositionOffsetY" ) ) );
771 aWrappedProperties
.push_back( new WrappedProperty( C2U( "SolidType" ), C2U( "Geometry3D" ) ) );
772 aWrappedProperties
.push_back( new WrappedSegmentOffsetProperty() );
773 aWrappedProperties
.push_back( new WrappedProperty( C2U( "D3DPercentDiagonal" ), C2U( "PercentDiagonal" ) ) );
775 aWrappedProperties
.push_back( new WrappedTextRotationProperty() );
777 return aWrappedProperties
;
780 void SAL_CALL
DataSeriesPointWrapper::setPropertyValue( const ::rtl::OUString
& rPropertyName
, const Any
& rValue
)
781 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
783 if(rPropertyName
.equals(C2U("Lines")))
785 if( ! (rValue
>>= m_bLinesAllowed
) )
786 throw lang::IllegalArgumentException( C2U("Property Lines requires value of type sal_Bool"), 0, 0 );
789 sal_Int32 nHandle
= getInfoHelper().getHandleByName( rPropertyName
);
790 static const sal_Int32 nErrorCategoryHandle
= getInfoHelper().getHandleByName( C2U("ErrorCategory") );
791 if( nErrorCategoryHandle
== nHandle
)
793 ::com::sun::star::chart::ChartErrorCategory aNewValue
= ::com::sun::star::chart::ChartErrorCategory_NONE
;
794 rValue
>>= aNewValue
;
796 bool bSetHighAndLowValues
= false;
799 case ::com::sun::star::chart::ChartErrorCategory_CONSTANT_VALUE
:
800 aHigh
= this->getPropertyValue(C2U("ConstantErrorHigh"));
801 aLow
= this->getPropertyValue(C2U("ConstantErrorLow"));
802 bSetHighAndLowValues
= true;
804 case ::com::sun::star::chart::ChartErrorCategory_PERCENT
:
805 aHigh
= aLow
= this->getPropertyValue(C2U("PercentageError"));
806 bSetHighAndLowValues
= true;
808 case ::com::sun::star::chart::ChartErrorCategory_ERROR_MARGIN
:
809 aHigh
= aLow
= this->getPropertyValue(C2U("ErrorMargin"));
810 bSetHighAndLowValues
= true;
816 WrappedPropertySet::setPropertyValue( rPropertyName
, rValue
);
818 if(bSetHighAndLowValues
)
822 case ::com::sun::star::chart::ChartErrorCategory_CONSTANT_VALUE
:
823 this->setPropertyValue(C2U("ConstantErrorHigh"),aHigh
);
824 this->setPropertyValue(C2U("ConstantErrorLow"),aLow
);
826 case ::com::sun::star::chart::ChartErrorCategory_PERCENT
:
827 this->setPropertyValue(C2U("PercentageError"),aHigh
);
829 case ::com::sun::star::chart::ChartErrorCategory_ERROR_MARGIN
:
830 this->setPropertyValue(C2U("ErrorMargin"),aHigh
);
838 WrappedPropertySet::setPropertyValue( rPropertyName
, rValue
);
841 Any SAL_CALL
DataSeriesPointWrapper::getPropertyValue( const rtl::OUString
& rPropertyName
)
842 throw ( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
844 if( m_eType
== DATA_POINT
)
846 if( rPropertyName
.equals(C2U("FillColor")) )
848 Reference
< beans::XPropertySet
> xSeriesProp( getDataSeries(), uno::UNO_QUERY
);
849 sal_Bool bVaryColorsByPoint
= sal_False
;
850 if( xSeriesProp
.is() && (xSeriesProp
->getPropertyValue( C2U("VaryColorsByPoint") ) >>= bVaryColorsByPoint
)
851 && bVaryColorsByPoint
)
853 uno::Reference
< beans::XPropertyState
> xPointState( DataSeriesPointWrapper::getDataPointProperties(), uno::UNO_QUERY
);
854 if( xPointState
.is() && xPointState
->getPropertyState( C2U("Color")) == beans::PropertyState_DEFAULT_VALUE
)
856 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
859 Reference
< chart2::XColorScheme
> xColorScheme( xDiagram
->getDefaultColorScheme() );
860 if( xColorScheme
.is() )
861 return uno::makeAny( xColorScheme
->getColorByIndex( m_nPointIndex
) );
867 return WrappedPropertySet::getPropertyValue( rPropertyName
);
870 // ================================================================================
872 uno::Sequence
< ::rtl::OUString
> DataSeriesPointWrapper::getSupportedServiceNames_Static()
874 uno::Sequence
< ::rtl::OUString
> aServices( 7 );
875 aServices
[ 0 ] = C2U( "com.sun.star.chart.ChartDataRowProperties" );
876 aServices
[ 1 ] = C2U( "com.sun.star.chart.ChartDataPointProperties" );
877 aServices
[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
878 aServices
[ 3 ] = C2U( "com.sun.star.beans.PropertySet" );
879 aServices
[ 4 ] = C2U( "com.sun.star.drawing.FillProperties" );
880 aServices
[ 5 ] = C2U( "com.sun.star.drawing.LineProperties" );
881 aServices
[ 6 ] = C2U( "com.sun.star.style.CharacterProperties" );
886 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
887 APPHELPER_XSERVICEINFO_IMPL( DataSeriesPointWrapper
, lcl_aServiceName
);
889 } // namespace wrapper