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 "ChartDataWrapper.hxx" 31*cdf0e10cSrcweir #include "macros.hxx" 32*cdf0e10cSrcweir #include "DiagramHelper.hxx" 33*cdf0e10cSrcweir #include "DataSourceHelper.hxx" 34*cdf0e10cSrcweir #include "servicenames_charttypes.hxx" 35*cdf0e10cSrcweir #include "ContainerHelper.hxx" 36*cdf0e10cSrcweir #include "CommonFunctors.hxx" 37*cdf0e10cSrcweir #include "ChartModelHelper.hxx" 38*cdf0e10cSrcweir #include "DataSeriesHelper.hxx" 39*cdf0e10cSrcweir #include "ControllerLockGuard.hxx" 40*cdf0e10cSrcweir #include "Chart2ModelContact.hxx" 41*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/chart2/XTitled.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/chart2/data/XTextualDataSequence.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataSource.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/chart2/XDataSeries.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/chart2/XDataSeriesContainer.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/chart2/XChartTypeContainer.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataReceiver.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/chart/ChartDataRowSource.hpp> 52*cdf0e10cSrcweir #include <com/sun/star/chart/XChartDocument.hpp> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #include "CharacterProperties.hxx" 55*cdf0e10cSrcweir #include "LineProperties.hxx" 56*cdf0e10cSrcweir #include "FillProperties.hxx" 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #include <map> 59*cdf0e10cSrcweir #include <algorithm> 60*cdf0e10cSrcweir #include <rtl/math.hxx> 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir using namespace ::com::sun::star; 63*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 64*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 65*cdf0e10cSrcweir using ::rtl::OUString; 66*cdf0e10cSrcweir using ::osl::MutexGuard; 67*cdf0e10cSrcweir using ::com::sun::star::chart2::XAnyDescriptionAccess; 68*cdf0e10cSrcweir using ::com::sun::star::chart::XComplexDescriptionAccess; 69*cdf0e10cSrcweir using ::com::sun::star::chart::XChartData; 70*cdf0e10cSrcweir using ::com::sun::star::chart::XChartDataArray; 71*cdf0e10cSrcweir using ::com::sun::star::chart::XDateCategories; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir namespace 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir static const ::rtl::OUString lcl_aServiceName( 76*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.ChartData" )); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir uno::Sequence< uno::Sequence< double > > lcl_getNANInsteadDBL_MIN( const uno::Sequence< uno::Sequence< double > >& rData ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir uno::Sequence< uno::Sequence< double > > aRet; 81*cdf0e10cSrcweir const sal_Int32 nOuterSize = rData.getLength(); 82*cdf0e10cSrcweir aRet.realloc( nOuterSize ); 83*cdf0e10cSrcweir for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter ) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir sal_Int32 nInnerSize = rData[nOuter].getLength(); 86*cdf0e10cSrcweir aRet[nOuter].realloc( nInnerSize ); 87*cdf0e10cSrcweir for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner ) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir aRet[nOuter][nInner] = rData[nOuter][nInner]; 90*cdf0e10cSrcweir double& rValue = aRet[nOuter][nInner]; 91*cdf0e10cSrcweir if( rValue == DBL_MIN ) 92*cdf0e10cSrcweir ::rtl::math::setNan( &rValue ); 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir return aRet; 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir uno::Sequence< uno::Sequence< double > > lcl_getDBL_MINInsteadNAN( const uno::Sequence< uno::Sequence< double > >& rData ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir uno::Sequence< uno::Sequence< double > > aRet; 101*cdf0e10cSrcweir const sal_Int32 nOuterSize = rData.getLength(); 102*cdf0e10cSrcweir aRet.realloc( nOuterSize ); 103*cdf0e10cSrcweir for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir sal_Int32 nInnerSize = rData[nOuter].getLength(); 106*cdf0e10cSrcweir aRet[nOuter].realloc( nInnerSize ); 107*cdf0e10cSrcweir for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir aRet[nOuter][nInner] = rData[nOuter][nInner]; 110*cdf0e10cSrcweir double& rValue = aRet[nOuter][nInner]; 111*cdf0e10cSrcweir if( ::rtl::math::isNan( rValue ) ) 112*cdf0e10cSrcweir rValue = DBL_MIN; 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir return aRet; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir } // anonymous namespace 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir namespace chart 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir namespace wrapper 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir //-------------------------------------------------------------------------------------- 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir struct lcl_Operator 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir lcl_Operator() 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir virtual ~lcl_Operator() 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) = 0; 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir virtual bool setsCategories( bool /*bDataInColumns*/ ) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir return false; 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir }; 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir //-------------------------------------------------------------------------- 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir struct lcl_AllOperator : public lcl_Operator 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir lcl_AllOperator( const Reference< XChartData >& xDataToApply ) 150*cdf0e10cSrcweir : lcl_Operator() 151*cdf0e10cSrcweir , m_xDataToApply( xDataToApply ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir virtual bool setsCategories( bool /*bDataInColumns*/ ) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir return true; 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir if( !xDataAccess.is() ) 163*cdf0e10cSrcweir return; 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir Reference< XAnyDescriptionAccess > xNewAny( m_xDataToApply, uno::UNO_QUERY ); 166*cdf0e10cSrcweir Reference< XComplexDescriptionAccess > xNewComplex( m_xDataToApply, uno::UNO_QUERY ); 167*cdf0e10cSrcweir if( xNewAny.is() ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir xDataAccess->setData( xNewAny->getData() ); 170*cdf0e10cSrcweir xDataAccess->setComplexRowDescriptions( xNewAny->getComplexRowDescriptions() ); 171*cdf0e10cSrcweir xDataAccess->setComplexColumnDescriptions( xNewAny->getComplexColumnDescriptions() ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir else if( xNewComplex.is() ) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir xDataAccess->setData( xNewComplex->getData() ); 176*cdf0e10cSrcweir xDataAccess->setComplexRowDescriptions( xNewComplex->getComplexRowDescriptions() ); 177*cdf0e10cSrcweir xDataAccess->setComplexColumnDescriptions( xNewComplex->getComplexColumnDescriptions() ); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir else 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir Reference< XChartDataArray > xNew( m_xDataToApply, uno::UNO_QUERY ); 182*cdf0e10cSrcweir if( xNew.is() ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir xDataAccess->setData( xNew->getData() ); 185*cdf0e10cSrcweir xDataAccess->setRowDescriptions( xNew->getRowDescriptions() ); 186*cdf0e10cSrcweir xDataAccess->setColumnDescriptions( xNew->getColumnDescriptions() ); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir Reference< XChartData > m_xDataToApply; 192*cdf0e10cSrcweir }; 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir //-------------------------------------------------------------------------- 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir struct lcl_DataOperator : public lcl_Operator 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir lcl_DataOperator( const Sequence< Sequence< double > >& rData ) 199*cdf0e10cSrcweir : lcl_Operator() 200*cdf0e10cSrcweir , m_rData( rData ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir if( xDataAccess.is() ) 207*cdf0e10cSrcweir xDataAccess->setData( lcl_getNANInsteadDBL_MIN( m_rData ) ); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir const Sequence< Sequence< double > >& m_rData; 211*cdf0e10cSrcweir }; 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir //-------------------------------------------------------------------------- 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir struct lcl_RowDescriptionsOperator : public lcl_Operator 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions 218*cdf0e10cSrcweir , const Reference< chart2::XChartDocument >& xChartDoc ) 219*cdf0e10cSrcweir : lcl_Operator() 220*cdf0e10cSrcweir , m_rRowDescriptions( rRowDescriptions ) 221*cdf0e10cSrcweir , m_xChartDoc(xChartDoc) 222*cdf0e10cSrcweir , m_bDataInColumns(true) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir virtual bool setsCategories( bool bDataInColumns ) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir m_bDataInColumns = bDataInColumns; 229*cdf0e10cSrcweir return bDataInColumns; 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir if( xDataAccess.is() ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir xDataAccess->setRowDescriptions( m_rRowDescriptions ); 237*cdf0e10cSrcweir if( m_bDataInColumns ) 238*cdf0e10cSrcweir DiagramHelper::switchToTextCategories( m_xChartDoc ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir const Sequence< OUString >& m_rRowDescriptions; 243*cdf0e10cSrcweir Reference< chart2::XChartDocument > m_xChartDoc; 244*cdf0e10cSrcweir bool m_bDataInColumns; 245*cdf0e10cSrcweir }; 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir //-------------------------------------------------------------------------- 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions 252*cdf0e10cSrcweir , const Reference< chart2::XChartDocument >& xChartDoc ) 253*cdf0e10cSrcweir : lcl_Operator() 254*cdf0e10cSrcweir , m_rComplexRowDescriptions( rComplexRowDescriptions ) 255*cdf0e10cSrcweir , m_xChartDoc(xChartDoc) 256*cdf0e10cSrcweir , m_bDataInColumns(true) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir virtual bool setsCategories( bool bDataInColumns ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir m_bDataInColumns = bDataInColumns; 263*cdf0e10cSrcweir return bDataInColumns; 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir if( xDataAccess.is() ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir xDataAccess->setComplexRowDescriptions( m_rComplexRowDescriptions ); 271*cdf0e10cSrcweir if( m_bDataInColumns ) 272*cdf0e10cSrcweir DiagramHelper::switchToTextCategories( m_xChartDoc ); 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir const Sequence< Sequence< OUString > >& m_rComplexRowDescriptions; 277*cdf0e10cSrcweir Reference< chart2::XChartDocument > m_xChartDoc; 278*cdf0e10cSrcweir bool m_bDataInColumns; 279*cdf0e10cSrcweir }; 280*cdf0e10cSrcweir //-------------------------------------------------------------------------- 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir struct lcl_AnyRowDescriptionsOperator : public lcl_Operator 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir lcl_AnyRowDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyRowDescriptions ) 285*cdf0e10cSrcweir : lcl_Operator() 286*cdf0e10cSrcweir , m_rAnyRowDescriptions( rAnyRowDescriptions ) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir virtual bool setsCategories( bool bDataInColumns ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir return bDataInColumns; 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir if( xDataAccess.is() ) 298*cdf0e10cSrcweir xDataAccess->setAnyRowDescriptions( m_rAnyRowDescriptions ); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir const Sequence< Sequence< uno::Any > >& m_rAnyRowDescriptions; 302*cdf0e10cSrcweir }; 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir //-------------------------------------------------------------------------- 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir struct lcl_ColumnDescriptionsOperator : public lcl_Operator 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions 309*cdf0e10cSrcweir , const Reference< chart2::XChartDocument >& xChartDoc ) 310*cdf0e10cSrcweir : lcl_Operator() 311*cdf0e10cSrcweir , m_rColumnDescriptions( rColumnDescriptions ) 312*cdf0e10cSrcweir , m_xChartDoc(xChartDoc) 313*cdf0e10cSrcweir , m_bDataInColumns(true) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir virtual bool setsCategories( bool bDataInColumns ) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir m_bDataInColumns = bDataInColumns; 320*cdf0e10cSrcweir return !bDataInColumns; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir if( xDataAccess.is() ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir xDataAccess->setColumnDescriptions( m_rColumnDescriptions ); 328*cdf0e10cSrcweir if( !m_bDataInColumns ) 329*cdf0e10cSrcweir DiagramHelper::switchToTextCategories( m_xChartDoc ); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir const Sequence< OUString >& m_rColumnDescriptions; 334*cdf0e10cSrcweir Reference< chart2::XChartDocument > m_xChartDoc; 335*cdf0e10cSrcweir bool m_bDataInColumns; 336*cdf0e10cSrcweir }; 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir //-------------------------------------------------------------------------- 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions 343*cdf0e10cSrcweir , const Reference< chart2::XChartDocument >& xChartDoc ) 344*cdf0e10cSrcweir : lcl_Operator() 345*cdf0e10cSrcweir , m_rComplexColumnDescriptions( rComplexColumnDescriptions ) 346*cdf0e10cSrcweir , m_xChartDoc(xChartDoc) 347*cdf0e10cSrcweir , m_bDataInColumns(true) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir virtual bool setsCategories( bool bDataInColumns ) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir m_bDataInColumns = bDataInColumns; 354*cdf0e10cSrcweir return !bDataInColumns; 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir if( xDataAccess.is() ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir xDataAccess->setComplexColumnDescriptions( m_rComplexColumnDescriptions ); 362*cdf0e10cSrcweir if( !m_bDataInColumns ) 363*cdf0e10cSrcweir DiagramHelper::switchToTextCategories( m_xChartDoc ); 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir const Sequence< Sequence< OUString > >& m_rComplexColumnDescriptions; 368*cdf0e10cSrcweir Reference< chart2::XChartDocument > m_xChartDoc; 369*cdf0e10cSrcweir bool m_bDataInColumns; 370*cdf0e10cSrcweir }; 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir //-------------------------------------------------------------------------- 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir struct lcl_AnyColumnDescriptionsOperator : public lcl_Operator 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir lcl_AnyColumnDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyColumnDescriptions ) 377*cdf0e10cSrcweir : lcl_Operator() 378*cdf0e10cSrcweir , m_rAnyColumnDescriptions( rAnyColumnDescriptions ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir virtual bool setsCategories( bool bDataInColumns ) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir return bDataInColumns; 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir if( xDataAccess.is() ) 390*cdf0e10cSrcweir xDataAccess->setAnyColumnDescriptions( m_rAnyColumnDescriptions ); 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir const Sequence< Sequence< uno::Any > >& m_rAnyColumnDescriptions; 394*cdf0e10cSrcweir }; 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir //-------------------------------------------------------------------------- 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir struct lcl_DateCategoriesOperator : public lcl_Operator 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir lcl_DateCategoriesOperator( const Sequence< double >& rDates ) 401*cdf0e10cSrcweir : lcl_Operator() 402*cdf0e10cSrcweir , m_rDates( rDates ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir virtual bool setsCategories( bool /*bDataInColumns*/ ) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir return true; 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir Reference< XDateCategories > xDateCategories( xDataAccess, uno::UNO_QUERY ); 414*cdf0e10cSrcweir if( xDateCategories.is() ) 415*cdf0e10cSrcweir xDateCategories->setDateCategories( m_rDates ); 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir const Sequence< double >& m_rDates; 419*cdf0e10cSrcweir }; 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir //-------------------------------------------------------------------------- 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir ChartDataWrapper::ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : 424*cdf0e10cSrcweir m_spChart2ModelContact( spChart2ModelContact ), 425*cdf0e10cSrcweir m_aEventListenerContainer( m_aMutex ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 428*cdf0e10cSrcweir initDataAccess(); 429*cdf0e10cSrcweir osl_decrementInterlockedCount( &m_refCount ); 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir ChartDataWrapper::ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, 433*cdf0e10cSrcweir const Reference< XChartData >& xNewData ) : 434*cdf0e10cSrcweir m_spChart2ModelContact( spChart2ModelContact ), 435*cdf0e10cSrcweir m_aEventListenerContainer( m_aMutex ) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 438*cdf0e10cSrcweir lcl_AllOperator aOperator( xNewData ); 439*cdf0e10cSrcweir applyData( aOperator ); 440*cdf0e10cSrcweir osl_decrementInterlockedCount( &m_refCount ); 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir ChartDataWrapper::~ChartDataWrapper() 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir // @todo: implement XComponent and call this in dispose(). In the DTOR the 446*cdf0e10cSrcweir // ref-count is 0, thus creating a stack reference to this calls the DTOR at 447*cdf0e10cSrcweir // the end of the block recursively 448*cdf0e10cSrcweir // uno::Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); 449*cdf0e10cSrcweir // m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir // ____ XChartDataArray (read)____ 453*cdf0e10cSrcweir Sequence< Sequence< double > > SAL_CALL ChartDataWrapper::getData() 454*cdf0e10cSrcweir throw (uno::RuntimeException) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir initDataAccess(); 457*cdf0e10cSrcweir if( m_xDataAccess.is() ) 458*cdf0e10cSrcweir return lcl_getDBL_MINInsteadNAN( m_xDataAccess->getData() ); 459*cdf0e10cSrcweir return Sequence< Sequence< double > >(); 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir Sequence< OUString > SAL_CALL ChartDataWrapper::getRowDescriptions() 462*cdf0e10cSrcweir throw (uno::RuntimeException) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir initDataAccess(); 465*cdf0e10cSrcweir if( m_xDataAccess.is() ) 466*cdf0e10cSrcweir return m_xDataAccess->getRowDescriptions(); 467*cdf0e10cSrcweir return Sequence< OUString >(); 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir Sequence< OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions() 470*cdf0e10cSrcweir throw (uno::RuntimeException) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir initDataAccess(); 473*cdf0e10cSrcweir if( m_xDataAccess.is() ) 474*cdf0e10cSrcweir return m_xDataAccess->getColumnDescriptions(); 475*cdf0e10cSrcweir return Sequence< OUString > (); 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir // ____ XComplexDescriptionAccess (read) ____ 479*cdf0e10cSrcweir Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexRowDescriptions() throw (uno::RuntimeException) 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir initDataAccess(); 482*cdf0e10cSrcweir if( m_xDataAccess.is() ) 483*cdf0e10cSrcweir return m_xDataAccess->getComplexRowDescriptions(); 484*cdf0e10cSrcweir return Sequence< Sequence< OUString > >(); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexColumnDescriptions() throw (uno::RuntimeException) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir initDataAccess(); 489*cdf0e10cSrcweir if( m_xDataAccess.is() ) 490*cdf0e10cSrcweir return m_xDataAccess->getComplexColumnDescriptions(); 491*cdf0e10cSrcweir return Sequence< Sequence< OUString > >(); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir // ____ XAnyDescriptionAccess (read) ____ 495*cdf0e10cSrcweir Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyRowDescriptions() throw (uno::RuntimeException) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir initDataAccess(); 498*cdf0e10cSrcweir if( m_xDataAccess.is() ) 499*cdf0e10cSrcweir return m_xDataAccess->getAnyRowDescriptions(); 500*cdf0e10cSrcweir return Sequence< Sequence< uno::Any > >(); 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyColumnDescriptions() throw (uno::RuntimeException) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir initDataAccess(); 505*cdf0e10cSrcweir if( m_xDataAccess.is() ) 506*cdf0e10cSrcweir return m_xDataAccess->getAnyColumnDescriptions(); 507*cdf0e10cSrcweir return Sequence< Sequence< uno::Any > >(); 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir // ____ XDateCategories (read) ____ 511*cdf0e10cSrcweir Sequence< double > SAL_CALL ChartDataWrapper::getDateCategories() throw (uno::RuntimeException) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir initDataAccess(); 514*cdf0e10cSrcweir Reference< XDateCategories > xDateCategories( m_xDataAccess, uno::UNO_QUERY ); 515*cdf0e10cSrcweir if( xDateCategories.is() ) 516*cdf0e10cSrcweir return xDateCategories->getDateCategories(); 517*cdf0e10cSrcweir return Sequence< double >(); 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir // ____ XChartDataArray (write)____ 521*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& rData ) 522*cdf0e10cSrcweir throw (uno::RuntimeException) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir lcl_DataOperator aOperator( rData ); 525*cdf0e10cSrcweir applyData( aOperator ); 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::setRowDescriptions( const Sequence< OUString >& rRowDescriptions ) 528*cdf0e10cSrcweir throw (uno::RuntimeException) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir lcl_RowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() ); 531*cdf0e10cSrcweir applyData( aOperator ); 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::setColumnDescriptions( const Sequence< OUString >& rColumnDescriptions ) 534*cdf0e10cSrcweir throw (uno::RuntimeException) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() ); 537*cdf0e10cSrcweir applyData( aOperator ); 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir // ____ XComplexDescriptionAccess (write) ____ 541*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rRowDescriptions ) throw (uno::RuntimeException) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() ); 544*cdf0e10cSrcweir applyData( aOperator ); 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rColumnDescriptions ) throw (uno::RuntimeException) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() ); 549*cdf0e10cSrcweir applyData( aOperator ); 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir // ____ XAnyDescriptionAccess (write) ____ 553*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& rRowDescriptions ) throw (uno::RuntimeException) 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir lcl_AnyRowDescriptionsOperator aOperator( rRowDescriptions ); 556*cdf0e10cSrcweir applyData( aOperator ); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& rColumnDescriptions ) throw (uno::RuntimeException) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir lcl_AnyColumnDescriptionsOperator aOperator( rColumnDescriptions ); 561*cdf0e10cSrcweir applyData( aOperator ); 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir // ____ XDateCategories (write) ____ 565*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& rDates ) throw (uno::RuntimeException) 566*cdf0e10cSrcweir { 567*cdf0e10cSrcweir Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); 568*cdf0e10cSrcweir ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); 569*cdf0e10cSrcweir lcl_DateCategoriesOperator aOperator( rDates ); 570*cdf0e10cSrcweir applyData( aOperator ); 571*cdf0e10cSrcweir DiagramHelper::switchToDateCategories( xChartDoc ); 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir //-------------------------------------------------------------------------------------- 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir // ____ XChartData (base of XChartDataArray) ____ 577*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::addChartDataChangeEventListener( 578*cdf0e10cSrcweir const uno::Reference< 579*cdf0e10cSrcweir ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ) 580*cdf0e10cSrcweir throw (uno::RuntimeException) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir m_aEventListenerContainer.addInterface( aListener ); 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::removeChartDataChangeEventListener( 586*cdf0e10cSrcweir const uno::Reference< 587*cdf0e10cSrcweir ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ) 588*cdf0e10cSrcweir throw (uno::RuntimeException) 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir m_aEventListenerContainer.removeInterface( aListener ); 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir double SAL_CALL ChartDataWrapper::getNotANumber() 594*cdf0e10cSrcweir throw (uno::RuntimeException) 595*cdf0e10cSrcweir { 596*cdf0e10cSrcweir return DBL_MIN; 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir sal_Bool SAL_CALL ChartDataWrapper::isNotANumber( double nNumber ) 600*cdf0e10cSrcweir throw (uno::RuntimeException) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir return DBL_MIN == nNumber 603*cdf0e10cSrcweir || ::rtl::math::isNan( nNumber ) 604*cdf0e10cSrcweir || ::rtl::math::isInf( nNumber ); 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir // ____ XComponent ____ 608*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::dispose() 609*cdf0e10cSrcweir throw (uno::RuntimeException) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); 612*cdf0e10cSrcweir m_xDataAccess=0; 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::addEventListener( 616*cdf0e10cSrcweir const uno::Reference< lang::XEventListener > & xListener ) 617*cdf0e10cSrcweir throw (uno::RuntimeException) 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir m_aEventListenerContainer.addInterface( xListener ); 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::removeEventListener( 623*cdf0e10cSrcweir const uno::Reference< lang::XEventListener >& aListener ) 624*cdf0e10cSrcweir throw (uno::RuntimeException) 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir m_aEventListenerContainer.removeInterface( aListener ); 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir // ____ XEventListener ____ 630*cdf0e10cSrcweir void SAL_CALL ChartDataWrapper::disposing( const lang::EventObject& /* Source */ ) 631*cdf0e10cSrcweir throw (uno::RuntimeException) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir // ::com::sun::star::chart::ChartDataChangeEvent aEvent; 636*cdf0e10cSrcweir // aEvent.Type = chart::ChartDataChangeType_ALL; 637*cdf0e10cSrcweir // aEvent.StartColumn = 0; 638*cdf0e10cSrcweir // aEvent.EndColumn = 0; 639*cdf0e10cSrcweir // aEvent.StartRow = 0; 640*cdf0e10cSrcweir // aEvent.EndRow = 0; 641*cdf0e10cSrcweir void ChartDataWrapper::fireChartDataChangeEvent( 642*cdf0e10cSrcweir ::com::sun::star::chart::ChartDataChangeEvent& aEvent ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir if( ! m_aEventListenerContainer.getLength() ) 645*cdf0e10cSrcweir return; 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir uno::Reference< uno::XInterface > xSrc( static_cast< cppu::OWeakObject* >( this )); 648*cdf0e10cSrcweir OSL_ASSERT( xSrc.is()); 649*cdf0e10cSrcweir if( xSrc.is() ) 650*cdf0e10cSrcweir aEvent.Source = xSrc; 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIter( m_aEventListenerContainer ); 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir while( aIter.hasMoreElements() ) 655*cdf0e10cSrcweir { 656*cdf0e10cSrcweir uno::Reference< 657*cdf0e10cSrcweir ::com::sun::star::chart::XChartDataChangeEventListener > xListener( 658*cdf0e10cSrcweir aIter.next(), uno::UNO_QUERY ); 659*cdf0e10cSrcweir if( xListener.is() ) 660*cdf0e10cSrcweir xListener->chartDataChanged( aEvent ); 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir void ChartDataWrapper::switchToInternalDataProvider() 667*cdf0e10cSrcweir { 668*cdf0e10cSrcweir //create an internal data provider that is connected to the model 669*cdf0e10cSrcweir Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); 670*cdf0e10cSrcweir if( xChartDoc.is() ) 671*cdf0e10cSrcweir xChartDoc->createInternalDataProvider( true /*bCloneExistingData*/ ); 672*cdf0e10cSrcweir initDataAccess(); 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir void ChartDataWrapper::initDataAccess() 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); 678*cdf0e10cSrcweir if( !xChartDoc.is() ) 679*cdf0e10cSrcweir return; 680*cdf0e10cSrcweir if( xChartDoc->hasInternalDataProvider() ) 681*cdf0e10cSrcweir m_xDataAccess = Reference< XAnyDescriptionAccess >( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW ); 682*cdf0e10cSrcweir else 683*cdf0e10cSrcweir { 684*cdf0e10cSrcweir //create a separate "internal data provider" that is not connected to the model 685*cdf0e10cSrcweir m_xDataAccess = Reference< XAnyDescriptionAccess >( ChartModelHelper::createInternalDataProvider( 686*cdf0e10cSrcweir xChartDoc, false /*bConnectToModel*/ ), uno::UNO_QUERY_THROW ); 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) 691*cdf0e10cSrcweir { 692*cdf0e10cSrcweir //bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions 693*cdf0e10cSrcweir Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); 694*cdf0e10cSrcweir if( !xChartDoc.is() ) 695*cdf0e10cSrcweir return; 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir // remember some diagram properties to reset later 698*cdf0e10cSrcweir sal_Bool bStacked = sal_False; 699*cdf0e10cSrcweir sal_Bool bPercent = sal_False; 700*cdf0e10cSrcweir sal_Bool bDeep = sal_False; 701*cdf0e10cSrcweir uno::Reference< ::com::sun::star::chart::XChartDocument > xOldDoc( xChartDoc, uno::UNO_QUERY ); 702*cdf0e10cSrcweir OSL_ASSERT( xOldDoc.is()); 703*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xDiaProp( xOldDoc->getDiagram(), uno::UNO_QUERY ); 704*cdf0e10cSrcweir if( xDiaProp.is()) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir xDiaProp->getPropertyValue( C2U("Stacked")) >>= bStacked; 707*cdf0e10cSrcweir xDiaProp->getPropertyValue( C2U("Percent")) >>= bPercent; 708*cdf0e10cSrcweir xDiaProp->getPropertyValue( C2U("Deep")) >>= bDeep; 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir //detect arguments for the new data source 712*cdf0e10cSrcweir ::rtl::OUString aRangeString; 713*cdf0e10cSrcweir bool bUseColumns = true; 714*cdf0e10cSrcweir bool bFirstCellAsLabel = true; 715*cdf0e10cSrcweir bool bHasCategories = true; 716*cdf0e10cSrcweir uno::Sequence< sal_Int32 > aSequenceMapping; 717*cdf0e10cSrcweir 718*cdf0e10cSrcweir DataSourceHelper::detectRangeSegmentation( 719*cdf0e10cSrcweir uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ), 720*cdf0e10cSrcweir aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ); 721*cdf0e10cSrcweir 722*cdf0e10cSrcweir if( !bHasCategories && rDataOperator.setsCategories( bUseColumns ) ) 723*cdf0e10cSrcweir bHasCategories = true; 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir aRangeString = C2U("all"); 726*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aArguments( DataSourceHelper::createArguments( 727*cdf0e10cSrcweir aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ) ); 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir // /-- locked controllers 731*cdf0e10cSrcweir ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir // create and attach new data source 734*cdf0e10cSrcweir switchToInternalDataProvider(); 735*cdf0e10cSrcweir rDataOperator.apply(m_xDataAccess); 736*cdf0e10cSrcweir uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() ); 737*cdf0e10cSrcweir OSL_ASSERT( xDataProvider.is() ); 738*cdf0e10cSrcweir if( !xDataProvider.is() ) 739*cdf0e10cSrcweir return; 740*cdf0e10cSrcweir uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) ); 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram() ); 743*cdf0e10cSrcweir if( xDia.is() ) 744*cdf0e10cSrcweir xDia->setDiagramData( xSource, aArguments ); 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir //correct stacking mode 747*cdf0e10cSrcweir if( bStacked || bPercent || bDeep ) 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir StackMode eStackMode = StackMode_Y_STACKED; 750*cdf0e10cSrcweir if( bDeep ) 751*cdf0e10cSrcweir eStackMode = StackMode_Z_STACKED; 752*cdf0e10cSrcweir else if( bPercent ) 753*cdf0e10cSrcweir eStackMode = StackMode_Y_STACKED_PERCENT; 754*cdf0e10cSrcweir DiagramHelper::setStackMode( xDia, eStackMode ); 755*cdf0e10cSrcweir } 756*cdf0e10cSrcweir 757*cdf0e10cSrcweir // notify listeners 758*cdf0e10cSrcweir ::com::sun::star::chart::ChartDataChangeEvent aEvent( 759*cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >( this ), 760*cdf0e10cSrcweir ::com::sun::star::chart::ChartDataChangeType_ALL, 0, 0, 0, 0 ); 761*cdf0e10cSrcweir fireChartDataChangeEvent( aEvent ); 762*cdf0e10cSrcweir // \-- locked controllers 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > ChartDataWrapper::getSupportedServiceNames_Static() 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aServices( 2 ); 770*cdf0e10cSrcweir aServices[ 0 ] = C2U( "com.sun.star.chart.ChartDataArray" ); 771*cdf0e10cSrcweir aServices[ 1 ] = C2U( "com.sun.star.chart.ChartData" ); 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir return aServices; 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir // ================================================================================ 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir // implement XServiceInfo methods basing upon getSupportedServiceNames_Static 779*cdf0e10cSrcweir APPHELPER_XSERVICEINFO_IMPL( ChartDataWrapper, lcl_aServiceName ); 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir } // namespace wrapper 782*cdf0e10cSrcweir } // namespace chart 783