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