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