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