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