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