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 31*cdf0e10cSrcweir #include "ObjectNameProvider.hxx" 32*cdf0e10cSrcweir #include "ResId.hxx" 33*cdf0e10cSrcweir #include "Strings.hrc" 34*cdf0e10cSrcweir #include "macros.hxx" 35*cdf0e10cSrcweir #include "AxisHelper.hxx" 36*cdf0e10cSrcweir #include "ChartModelHelper.hxx" 37*cdf0e10cSrcweir #include "DiagramHelper.hxx" 38*cdf0e10cSrcweir #include "DataSeriesHelper.hxx" 39*cdf0e10cSrcweir #include "TitleHelper.hxx" 40*cdf0e10cSrcweir #include "AxisIndexDefines.hxx" 41*cdf0e10cSrcweir #include "ExplicitCategoriesProvider.hxx" 42*cdf0e10cSrcweir #include "CommonConverters.hxx" 43*cdf0e10cSrcweir #include "NumberFormatterWrapper.hxx" 44*cdf0e10cSrcweir #include "RegressionCurveHelper.hxx" 45*cdf0e10cSrcweir #include <rtl/math.hxx> 46*cdf0e10cSrcweir #include <tools/debug.hxx> 47*cdf0e10cSrcweir #include <tools/string.hxx> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include <com/sun/star/chart2/XTitle.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir //............................................................................. 53*cdf0e10cSrcweir namespace chart 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir //............................................................................. 56*cdf0e10cSrcweir using namespace ::com::sun::star; 57*cdf0e10cSrcweir using namespace ::com::sun::star::chart2; 58*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 59*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 60*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 61*cdf0e10cSrcweir using rtl::OUString; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir namespace 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir OUString lcl_getDataSeriesName( const rtl::OUString& rObjectCID, const Reference< frame::XModel >& xChartModel ) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir OUString aRet; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); 71*cdf0e10cSrcweir Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY ); 72*cdf0e10cSrcweir if( xDiagram.is() && xSeries.is() ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); 75*cdf0e10cSrcweir if( xChartType.is() ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir aRet = ::chart::DataSeriesHelper::getDataSeriesLabel( 78*cdf0e10cSrcweir xSeries, xChartType->getRoleOfSequenceForSeriesLabel() ) ; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir return aRet; 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir OUString lcl_getFullSeriesName( const rtl::OUString& rObjectCID, const Reference< frame::XModel >& xChartModel ) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir OUString aRet = String(SchResId(STR_TIP_DATASERIES)); 88*cdf0e10cSrcweir OUString aWildcard( C2U("%SERIESNAME") ); 89*cdf0e10cSrcweir sal_Int32 nIndex = aRet.indexOf( aWildcard ); 90*cdf0e10cSrcweir if( nIndex != -1 ) 91*cdf0e10cSrcweir aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) ); 92*cdf0e10cSrcweir return aRet; 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir void lcl_addText( OUString& rOut, const OUString& rSeparator, const OUString& rNext ) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir if( rOut.getLength() && rNext.getLength() ) 98*cdf0e10cSrcweir rOut+=rSeparator; 99*cdf0e10cSrcweir if( rNext.getLength() ) 100*cdf0e10cSrcweir rOut+=rNext; 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal_Int32 nPointIndex, 104*cdf0e10cSrcweir const Reference< XCoordinateSystem >& xCooSys, 105*cdf0e10cSrcweir const Reference< frame::XModel >& xChartModel ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir OUString aRet; 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir Reference<data::XDataSource> xDataSource( 111*cdf0e10cSrcweir uno::Reference<data::XDataSource>( xSeries, uno::UNO_QUERY ) ); 112*cdf0e10cSrcweir if(!xDataSource.is()) 113*cdf0e10cSrcweir return aRet; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir Sequence< Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir rtl::OUString aX, aY, aY_Min, aY_Max, aY_First, aY_Last, a_Size; 118*cdf0e10cSrcweir double fValue = 0; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY ); 121*cdf0e10cSrcweir NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier ); 122*cdf0e10cSrcweir sal_Int32 nLabelColor = 0;//dummy 123*cdf0e10cSrcweir bool bColorChanged;//dummy 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir for(sal_Int32 nN = aDataSequences.getLength();nN--;) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir uno::Reference<data::XDataSequence> xDataSequence( aDataSequences[nN]->getValues()); 128*cdf0e10cSrcweir if( !xDataSequence.is() ) 129*cdf0e10cSrcweir continue; 130*cdf0e10cSrcweir Sequence< Any > aData( xDataSequence->getData() ); 131*cdf0e10cSrcweir if( nPointIndex >= aData.getLength() ) 132*cdf0e10cSrcweir continue; 133*cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY ); 134*cdf0e10cSrcweir if( xProp.is()) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir try 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir uno::Any aARole = xProp->getPropertyValue( C2U( "Role" ) ); 139*cdf0e10cSrcweir rtl::OUString aRole; 140*cdf0e10cSrcweir aARole >>= aRole; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir if( aRole.equals(C2U("values-x")) ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir aData[nPointIndex]>>= fValue; 145*cdf0e10cSrcweir sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); 146*cdf0e10cSrcweir aX = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir else if( aRole.equals(C2U("values-y")) ) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir aData[nPointIndex]>>= fValue; 151*cdf0e10cSrcweir sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); 152*cdf0e10cSrcweir aY = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir else if( aRole.equals(C2U("values-first")) ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir aData[nPointIndex]>>= fValue; 157*cdf0e10cSrcweir sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); 158*cdf0e10cSrcweir aY_First = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir else if( aRole.equals(C2U("values-min")) ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir aData[nPointIndex]>>= fValue; 163*cdf0e10cSrcweir sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); 164*cdf0e10cSrcweir aY_Min = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir else if( aRole.equals(C2U("values-max")) ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir aData[nPointIndex]>>= fValue; 169*cdf0e10cSrcweir sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); 170*cdf0e10cSrcweir aY_Max = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir else if( aRole.equals(C2U("values-last")) ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir aData[nPointIndex]>>= fValue; 175*cdf0e10cSrcweir sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); 176*cdf0e10cSrcweir aY_Last = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir else if( aRole.equals(C2U("values-size")) ) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir aData[nPointIndex]>>= fValue; 181*cdf0e10cSrcweir sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); 182*cdf0e10cSrcweir a_Size = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir catch( uno::Exception& e ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir ASSERT_EXCEPTION( e ); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir if( aX.getLength() == 0 ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir aRet = ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, xChartModel, nPointIndex ); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir else 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir aRet = aX; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir OUString aSeparator(C2U(" ")); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir lcl_addText( aRet, aSeparator, aY ); 204*cdf0e10cSrcweir lcl_addText( aRet, aSeparator, aY_First ); 205*cdf0e10cSrcweir lcl_addText( aRet, aSeparator, aY_Min ); 206*cdf0e10cSrcweir lcl_addText( aRet, aSeparator, aY_Max ); 207*cdf0e10cSrcweir lcl_addText( aRet, aSeparator, aY_Last ); 208*cdf0e10cSrcweir lcl_addText( aRet, aSeparator, a_Size ); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir return aRet; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir } //end anonymous namespace 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir rtl::OUString ObjectNameProvider::getName( ObjectType eObjectType, bool bPlural ) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir rtl::OUString aRet; 218*cdf0e10cSrcweir switch( eObjectType ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir case OBJECTTYPE_PAGE: 221*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_PAGE)); 222*cdf0e10cSrcweir break; 223*cdf0e10cSrcweir case OBJECTTYPE_TITLE: 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir if(bPlural) 226*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLES)); 227*cdf0e10cSrcweir else 228*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLE)); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir break; 231*cdf0e10cSrcweir case OBJECTTYPE_LEGEND: 232*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_LEGEND)); 233*cdf0e10cSrcweir break; 234*cdf0e10cSrcweir case OBJECTTYPE_LEGEND_ENTRY: 235*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_LEGEND_SYMBOL));//@todo change string if we do differenciate symbol and legend entry in future 236*cdf0e10cSrcweir break; 237*cdf0e10cSrcweir case OBJECTTYPE_DIAGRAM: 238*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_DIAGRAM)); 239*cdf0e10cSrcweir break; 240*cdf0e10cSrcweir case OBJECTTYPE_DIAGRAM_WALL: 241*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_DIAGRAM_WALL)); 242*cdf0e10cSrcweir break; 243*cdf0e10cSrcweir case OBJECTTYPE_DIAGRAM_FLOOR: 244*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_DIAGRAM_FLOOR)); 245*cdf0e10cSrcweir break; 246*cdf0e10cSrcweir case OBJECTTYPE_AXIS: 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir if(bPlural) 249*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_AXES)); 250*cdf0e10cSrcweir else 251*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_AXIS)); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir break; 254*cdf0e10cSrcweir case OBJECTTYPE_AXIS_UNITLABEL: 255*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_LABEL));//@todo maybe a more concrete name 256*cdf0e10cSrcweir break; 257*cdf0e10cSrcweir case OBJECTTYPE_GRID: 258*cdf0e10cSrcweir case OBJECTTYPE_SUBGRID: //maybe todo: different names for subgrids 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir if(bPlural) 261*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_GRIDS)); 262*cdf0e10cSrcweir else 263*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_GRID)); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir break; 266*cdf0e10cSrcweir case OBJECTTYPE_DATA_SERIES: 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir if(bPlural) 269*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_DATASERIES_PLURAL)); 270*cdf0e10cSrcweir else 271*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_DATASERIES)); 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir break; 274*cdf0e10cSrcweir case OBJECTTYPE_DATA_POINT: 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir if(bPlural) 277*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_DATAPOINTS)); 278*cdf0e10cSrcweir else 279*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_DATAPOINT)); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir break; 282*cdf0e10cSrcweir case OBJECTTYPE_DATA_LABELS: 283*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_DATALABELS)); 284*cdf0e10cSrcweir break; 285*cdf0e10cSrcweir case OBJECTTYPE_DATA_LABEL: 286*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_LABEL)); 287*cdf0e10cSrcweir break; 288*cdf0e10cSrcweir case OBJECTTYPE_DATA_ERRORS: 289*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe distinguish plural singular 290*cdf0e10cSrcweir break; 291*cdf0e10cSrcweir case OBJECTTYPE_DATA_ERRORS_X: 292*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe specialize in future 293*cdf0e10cSrcweir break; 294*cdf0e10cSrcweir case OBJECTTYPE_DATA_ERRORS_Y: 295*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe specialize in future 296*cdf0e10cSrcweir break; 297*cdf0e10cSrcweir case OBJECTTYPE_DATA_ERRORS_Z: 298*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe specialize in future 299*cdf0e10cSrcweir break; 300*cdf0e10cSrcweir case OBJECTTYPE_DATA_AVERAGE_LINE: 301*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_AVERAGE_LINE)); 302*cdf0e10cSrcweir break; 303*cdf0e10cSrcweir case OBJECTTYPE_DATA_CURVE: 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir if(bPlural) 306*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_CURVES)); 307*cdf0e10cSrcweir else 308*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_CURVE)); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir break; 311*cdf0e10cSrcweir case OBJECTTYPE_DATA_STOCK_RANGE: 312*cdf0e10cSrcweir //aRet=String(SchResId()); 313*cdf0e10cSrcweir break; 314*cdf0e10cSrcweir case OBJECTTYPE_DATA_STOCK_LOSS: 315*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_STOCK_LOSS)); 316*cdf0e10cSrcweir break; 317*cdf0e10cSrcweir case OBJECTTYPE_DATA_STOCK_GAIN: 318*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_STOCK_GAIN)); 319*cdf0e10cSrcweir break; 320*cdf0e10cSrcweir case OBJECTTYPE_DATA_CURVE_EQUATION: 321*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_CURVE_EQUATION)); 322*cdf0e10cSrcweir break; 323*cdf0e10cSrcweir default: //OBJECTTYPE_UNKNOWN 324*cdf0e10cSrcweir ; 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir return aRet; 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir rtl::OUString ObjectNameProvider::getAxisName( const rtl::OUString& rObjectCID 330*cdf0e10cSrcweir , const uno::Reference< frame::XModel >& xChartModel ) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir rtl::OUString aRet; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir Reference< XAxis > xAxis( 337*cdf0e10cSrcweir ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY ); 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir sal_Int32 nCooSysIndex = 0; 340*cdf0e10cSrcweir sal_Int32 nDimensionIndex = 0; 341*cdf0e10cSrcweir sal_Int32 nAxisIndex = 0; 342*cdf0e10cSrcweir AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ), nCooSysIndex, nDimensionIndex, nAxisIndex ); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir switch(nDimensionIndex) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir case 0://x-axis 347*cdf0e10cSrcweir if( nAxisIndex == 0 ) 348*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_AXIS_X)); 349*cdf0e10cSrcweir else 350*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_SECONDARY_X_AXIS)); 351*cdf0e10cSrcweir break; 352*cdf0e10cSrcweir case 1://y-axis 353*cdf0e10cSrcweir if( nAxisIndex == 0 ) 354*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_AXIS_Y)); 355*cdf0e10cSrcweir else 356*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_SECONDARY_Y_AXIS)); 357*cdf0e10cSrcweir break; 358*cdf0e10cSrcweir case 2://z-axis 359*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_AXIS_Z)); 360*cdf0e10cSrcweir break; 361*cdf0e10cSrcweir default://axis 362*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_AXIS)); 363*cdf0e10cSrcweir break; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir return aRet; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir OUString ObjectNameProvider::getTitleNameByType( TitleHelper::eTitleType eType ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir OUString aRet; 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir switch(eType) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir case TitleHelper::MAIN_TITLE: 376*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLE_MAIN)); 377*cdf0e10cSrcweir break; 378*cdf0e10cSrcweir case TitleHelper::SUB_TITLE: 379*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLE_SUB)); 380*cdf0e10cSrcweir break; 381*cdf0e10cSrcweir case TitleHelper::X_AXIS_TITLE: 382*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLE_X_AXIS)); 383*cdf0e10cSrcweir break; 384*cdf0e10cSrcweir case TitleHelper::Y_AXIS_TITLE: 385*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLE_Y_AXIS)); 386*cdf0e10cSrcweir break; 387*cdf0e10cSrcweir case TitleHelper::Z_AXIS_TITLE: 388*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLE_Z_AXIS)); 389*cdf0e10cSrcweir break; 390*cdf0e10cSrcweir case TitleHelper::SECONDARY_X_AXIS_TITLE: 391*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLE_SECONDARY_X_AXIS)); 392*cdf0e10cSrcweir break; 393*cdf0e10cSrcweir case TitleHelper::SECONDARY_Y_AXIS_TITLE: 394*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLE_SECONDARY_Y_AXIS)); 395*cdf0e10cSrcweir break; 396*cdf0e10cSrcweir default: 397*cdf0e10cSrcweir DBG_ERROR("unknown title type"); 398*cdf0e10cSrcweir break; 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir if( !aRet.getLength() ) 402*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLE)); 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir return aRet; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir OUString ObjectNameProvider::getTitleName( const OUString& rObjectCID 408*cdf0e10cSrcweir , const Reference< frame::XModel >& xChartModel ) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir OUString aRet; 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir Reference< XTitle > xTitle( 413*cdf0e10cSrcweir ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY ); 414*cdf0e10cSrcweir if( xTitle.is() ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir TitleHelper::eTitleType eType; 417*cdf0e10cSrcweir if( TitleHelper::getTitleType( eType, xTitle, xChartModel ) ) 418*cdf0e10cSrcweir aRet = ObjectNameProvider::getTitleNameByType( eType ); 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir if( !aRet.getLength() ) 421*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_TITLE)); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir return aRet; 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir rtl::OUString ObjectNameProvider::getGridName( const rtl::OUString& rObjectCID 427*cdf0e10cSrcweir , const uno::Reference< frame::XModel >& xChartModel ) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir rtl::OUString aRet; 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir sal_Int32 nCooSysIndex = -1; 433*cdf0e10cSrcweir sal_Int32 nDimensionIndex = -1; 434*cdf0e10cSrcweir sal_Int32 nAxisIndex = -1; 435*cdf0e10cSrcweir Reference< XAxis > xAxis( ObjectIdentifier::getAxisForCID( rObjectCID , xChartModel ) ); 436*cdf0e10cSrcweir AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ) 437*cdf0e10cSrcweir , nCooSysIndex , nDimensionIndex, nAxisIndex ); 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir bool bMainGrid = (ObjectIdentifier::getObjectType( rObjectCID ) == OBJECTTYPE_GRID); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir if( bMainGrid ) 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir switch(nDimensionIndex) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir case 0://x-axis 446*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_GRID_MAJOR_X)); 447*cdf0e10cSrcweir break; 448*cdf0e10cSrcweir case 1://y-axis 449*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_GRID_MAJOR_Y)); 450*cdf0e10cSrcweir break; 451*cdf0e10cSrcweir case 2://z-axis 452*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_GRID_MAJOR_Z)); 453*cdf0e10cSrcweir break; 454*cdf0e10cSrcweir default://axis 455*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_GRID)); 456*cdf0e10cSrcweir break; 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir else 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir switch(nDimensionIndex) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir case 0://x-axis 464*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_GRID_MINOR_X)); 465*cdf0e10cSrcweir break; 466*cdf0e10cSrcweir case 1://y-axis 467*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_GRID_MINOR_Y)); 468*cdf0e10cSrcweir break; 469*cdf0e10cSrcweir case 2://z-axis 470*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_GRID_MINOR_Z)); 471*cdf0e10cSrcweir break; 472*cdf0e10cSrcweir default://axis 473*cdf0e10cSrcweir aRet=String(SchResId(STR_OBJECT_GRID)); 474*cdf0e10cSrcweir break; 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir return aRet; 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir rtl::OUString ObjectNameProvider::getHelpText( const rtl::OUString& rObjectCID, const Reference< chart2::XChartDocument >& xChartDocument, bool bVerbose ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir return getHelpText( rObjectCID, Reference< frame::XModel >( xChartDocument, uno::UNO_QUERY ), bVerbose ); 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir rtl::OUString ObjectNameProvider::getHelpText( const rtl::OUString& rObjectCID, const Reference< frame::XModel >& xChartModel, bool bVerbose ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir rtl::OUString aRet; 488*cdf0e10cSrcweir ObjectType eObjectType( ObjectIdentifier::getObjectType(rObjectCID) ); 489*cdf0e10cSrcweir if( OBJECTTYPE_AXIS == eObjectType ) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir aRet=ObjectNameProvider::getAxisName( rObjectCID, xChartModel ); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir else if( OBJECTTYPE_GRID == eObjectType 494*cdf0e10cSrcweir || OBJECTTYPE_SUBGRID == eObjectType ) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir aRet=ObjectNameProvider::getGridName( rObjectCID, xChartModel ); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir else if( OBJECTTYPE_TITLE == eObjectType ) 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir aRet=ObjectNameProvider::getTitleName( rObjectCID, xChartModel ); 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir else if( OBJECTTYPE_DATA_SERIES == eObjectType ) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir aRet = lcl_getFullSeriesName( rObjectCID, xChartModel ); 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir else if( OBJECTTYPE_DATA_POINT == eObjectType ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir if( bVerbose ) 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir OUString aNewLine(C2U("\n")); 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir aRet=String(SchResId(STR_TIP_DATAPOINT_INDEX)); 513*cdf0e10cSrcweir aRet+=aNewLine; 514*cdf0e10cSrcweir aRet+=String(SchResId(STR_TIP_DATASERIES)); 515*cdf0e10cSrcweir aRet+=aNewLine; 516*cdf0e10cSrcweir aRet+=String(SchResId(STR_TIP_DATAPOINT_VALUES)); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir else 519*cdf0e10cSrcweir aRet=String(SchResId(STR_TIP_DATAPOINT)); 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); 522*cdf0e10cSrcweir Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY ); 523*cdf0e10cSrcweir if( xDiagram.is() && xSeries.is() ) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() ); 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir //replace data point index 528*cdf0e10cSrcweir sal_Int32 nIndex = -1; 529*cdf0e10cSrcweir OUString aWildcard( C2U("%POINTNUMBER") ); 530*cdf0e10cSrcweir nIndex = aRet.indexOf( aWildcard ); 531*cdf0e10cSrcweir if( nIndex != -1 ) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), OUString::valueOf(nPointIndex+1) ); 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir //replace data series index 537*cdf0e10cSrcweir aWildcard = C2U("%SERIESNUMBER"); 538*cdf0e10cSrcweir nIndex = aRet.indexOf( aWildcard ); 539*cdf0e10cSrcweir if( nIndex != -1 ) 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( 542*cdf0e10cSrcweir DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); 543*cdf0e10cSrcweir sal_Int32 nSeriesIndex = -1; 544*cdf0e10cSrcweir for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir if( aSeriesVector[nSeriesIndex] == xSeries ) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir break; 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir OUString aReplacement( OUString::valueOf(nSeriesIndex+1) ); 553*cdf0e10cSrcweir aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), aReplacement ); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir //replace point values 557*cdf0e10cSrcweir aWildcard = C2U("%POINTVALUES"); 558*cdf0e10cSrcweir nIndex = aRet.indexOf( aWildcard ); 559*cdf0e10cSrcweir if( nIndex != -1 ) 560*cdf0e10cSrcweir aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataPointValueText( 561*cdf0e10cSrcweir xSeries,nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartModel ) ); 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir //replace series name 564*cdf0e10cSrcweir aWildcard = C2U("%SERIESNAME"); 565*cdf0e10cSrcweir nIndex = aRet.indexOf( aWildcard ); 566*cdf0e10cSrcweir if( nIndex != -1 ) 567*cdf0e10cSrcweir aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) ); 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir /* 571*cdf0e10cSrcweir else if( OBJECTTYPE_DIAGRAM == eObjectType ) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir //todo different names for different diagram types ??? 574*cdf0e10cSrcweir //or different names for series of diferent charttypes 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir */ 577*cdf0e10cSrcweir else if( OBJECTTYPE_DATA_CURVE == eObjectType ) 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir if( bVerbose ) 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir aRet = String( SchResId( STR_OBJECT_CURVE_WITH_PARAMETERS )); 582*cdf0e10cSrcweir Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel )); 583*cdf0e10cSrcweir Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); 584*cdf0e10cSrcweir if( xCurveCnt.is()) 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt )); 587*cdf0e10cSrcweir if( xCurve.is()) 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir try 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_QUERY_THROW ); 592*cdf0e10cSrcweir RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel ); 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir // replace formula 595*cdf0e10cSrcweir sal_Int32 nIndex = -1; 596*cdf0e10cSrcweir OUString aWildcard( C2U("%FORMULA") ); 597*cdf0e10cSrcweir nIndex = aRet.indexOf( aWildcard ); 598*cdf0e10cSrcweir if( nIndex != -1 ) 599*cdf0e10cSrcweir aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), xCalculator->getRepresentation()); 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir // replace r^2 602*cdf0e10cSrcweir aWildcard = C2U("%RSQUARED"); 603*cdf0e10cSrcweir nIndex = aRet.indexOf( aWildcard ); 604*cdf0e10cSrcweir if( nIndex != -1 ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir sal_Unicode aDecimalSep( '.' ); 607*cdf0e10cSrcweir //@todo: enable this code when a localized decimal 608*cdf0e10cSrcweir //separator is also available for the formula 609*cdf0e10cSrcweir // SvtSysLocale aSysLocale; 610*cdf0e10cSrcweir // OUString aSep( aSysLocale.GetLocaleData().getNumDecimalSep()); 611*cdf0e10cSrcweir // if( aSep.getLength() == 1 ) 612*cdf0e10cSrcweir // aDecimalSep = aSep.toChar(); 613*cdf0e10cSrcweir double fR( xCalculator->getCorrelationCoefficient()); 614*cdf0e10cSrcweir aRet = aRet.replaceAt( 615*cdf0e10cSrcweir nIndex, aWildcard.getLength(), 616*cdf0e10cSrcweir ::rtl::math::doubleToUString( 617*cdf0e10cSrcweir fR*fR, rtl_math_StringFormat_G, 4, aDecimalSep, true )); 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir catch( const uno::Exception & ex ) 621*cdf0e10cSrcweir { 622*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir } 627*cdf0e10cSrcweir else 628*cdf0e10cSrcweir { 629*cdf0e10cSrcweir // non-verbose 630*cdf0e10cSrcweir aRet = ObjectNameProvider::getName( eObjectType, false ); 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir else if( OBJECTTYPE_DATA_AVERAGE_LINE == eObjectType ) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir if( bVerbose ) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir aRet = String( SchResId( STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS )); 638*cdf0e10cSrcweir Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel )); 639*cdf0e10cSrcweir Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); 640*cdf0e10cSrcweir if( xCurveCnt.is()) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getMeanValueLine( xCurveCnt )); 643*cdf0e10cSrcweir if( xCurve.is()) 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir try 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_QUERY_THROW ); 648*cdf0e10cSrcweir RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel ); 649*cdf0e10cSrcweir 650*cdf0e10cSrcweir sal_Unicode aDecimalSep( '.' ); 651*cdf0e10cSrcweir // replace average value 652*cdf0e10cSrcweir // SvtSysLocale aSysLocale; 653*cdf0e10cSrcweir // OUString aSep( aSysLocale.GetLocaleData().getNumDecimalSep()); 654*cdf0e10cSrcweir // if( aSep.getLength() == 1 ) 655*cdf0e10cSrcweir // aDecimalSep = aSep.toChar(); 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir sal_Int32 nIndex = -1; 658*cdf0e10cSrcweir OUString aWildcard( C2U("%AVERAGE_VALUE") ); 659*cdf0e10cSrcweir nIndex = aRet.indexOf( aWildcard ); 660*cdf0e10cSrcweir // as the curve is constant, the value at any x-value is ok 661*cdf0e10cSrcweir if( nIndex != -1 ) 662*cdf0e10cSrcweir { 663*cdf0e10cSrcweir const double fMeanValue( xCalculator->getCurveValue( 0.0 )); 664*cdf0e10cSrcweir aRet = aRet.replaceAt( 665*cdf0e10cSrcweir nIndex, aWildcard.getLength(), 666*cdf0e10cSrcweir ::rtl::math::doubleToUString( 667*cdf0e10cSrcweir fMeanValue, rtl_math_StringFormat_G, 4, aDecimalSep, true )); 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir // replace standard deviation 671*cdf0e10cSrcweir aWildcard = C2U("%STD_DEVIATION"); 672*cdf0e10cSrcweir nIndex = aRet.indexOf( aWildcard ); 673*cdf0e10cSrcweir if( nIndex != -1 ) 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir const double fStdDev( xCalculator->getCorrelationCoefficient()); 676*cdf0e10cSrcweir aRet = aRet.replaceAt( 677*cdf0e10cSrcweir nIndex, aWildcard.getLength(), 678*cdf0e10cSrcweir ::rtl::math::doubleToUString( 679*cdf0e10cSrcweir fStdDev, rtl_math_StringFormat_G, 4, aDecimalSep, true )); 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir catch( const uno::Exception & ex ) 683*cdf0e10cSrcweir { 684*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 685*cdf0e10cSrcweir } 686*cdf0e10cSrcweir } 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir else 690*cdf0e10cSrcweir { 691*cdf0e10cSrcweir // non-verbose 692*cdf0e10cSrcweir aRet = ObjectNameProvider::getName( eObjectType, false ); 693*cdf0e10cSrcweir } 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir else 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir aRet = ObjectNameProvider::getName( eObjectType, false ); 698*cdf0e10cSrcweir } 699*cdf0e10cSrcweir return aRet; 700*cdf0e10cSrcweir } 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir rtl::OUString ObjectNameProvider::getSelectedObjectText( const rtl::OUString & rObjectCID, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDocument ) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir rtl::OUString aRet; 705*cdf0e10cSrcweir ObjectType eObjectType( ObjectIdentifier::getObjectType(rObjectCID) ); 706*cdf0e10cSrcweir Reference< frame::XModel > xChartModel( xChartDocument, uno::UNO_QUERY ); 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir if( OBJECTTYPE_DATA_POINT == eObjectType ) 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir aRet = String( SchResId( STR_STATUS_DATAPOINT_MARKED )); 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); 713*cdf0e10cSrcweir Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY ); 714*cdf0e10cSrcweir if( xDiagram.is() && xSeries.is() ) 715*cdf0e10cSrcweir { 716*cdf0e10cSrcweir sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() ); 717*cdf0e10cSrcweir 718*cdf0e10cSrcweir // replace data point index 719*cdf0e10cSrcweir replaceParamterInString( aRet, C2U("%POINTNUMBER"), OUString::valueOf( nPointIndex + 1 )); 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir // replace data series index 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( 724*cdf0e10cSrcweir DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); 725*cdf0e10cSrcweir sal_Int32 nSeriesIndex = -1; 726*cdf0e10cSrcweir for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir if( aSeriesVector[nSeriesIndex] == xSeries ) 729*cdf0e10cSrcweir break; 730*cdf0e10cSrcweir } 731*cdf0e10cSrcweir replaceParamterInString( aRet, C2U("%SERIESNUMBER"), OUString::valueOf( nSeriesIndex + 1 ) ); 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir // replace point value 735*cdf0e10cSrcweir replaceParamterInString( aRet, C2U("%POINTVALUES"), lcl_getDataPointValueText( 736*cdf0e10cSrcweir xSeries, nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartModel ) ); 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir } 739*cdf0e10cSrcweir else 740*cdf0e10cSrcweir { 741*cdf0e10cSrcweir // use the verbose text including the formula for trend lines 742*cdf0e10cSrcweir const bool bVerbose( OBJECTTYPE_DATA_CURVE == eObjectType || OBJECTTYPE_DATA_AVERAGE_LINE == eObjectType ); 743*cdf0e10cSrcweir const OUString aHelpText( getHelpText( rObjectCID, xChartModel, bVerbose )); 744*cdf0e10cSrcweir if( aHelpText.getLength()) 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir aRet = String( SchResId( STR_STATUS_OBJECT_MARKED )); 747*cdf0e10cSrcweir replaceParamterInString( aRet, C2U("%OBJECTNAME"), aHelpText ); 748*cdf0e10cSrcweir } 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir return aRet; 752*cdf0e10cSrcweir } 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir rtl::OUString ObjectNameProvider::getNameForCID( 755*cdf0e10cSrcweir const rtl::OUString& rObjectCID, 756*cdf0e10cSrcweir const uno::Reference< chart2::XChartDocument >& xChartDocument ) 757*cdf0e10cSrcweir { 758*cdf0e10cSrcweir ObjectType eType( ObjectIdentifier::getObjectType( rObjectCID )); 759*cdf0e10cSrcweir Reference< frame::XModel > xModel( xChartDocument, uno::UNO_QUERY ); 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir switch( eType ) 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir case OBJECTTYPE_AXIS: 764*cdf0e10cSrcweir return getAxisName( rObjectCID, xModel ); 765*cdf0e10cSrcweir case OBJECTTYPE_TITLE: 766*cdf0e10cSrcweir return getTitleName( rObjectCID, xModel ); 767*cdf0e10cSrcweir case OBJECTTYPE_GRID: 768*cdf0e10cSrcweir case OBJECTTYPE_SUBGRID: 769*cdf0e10cSrcweir return getGridName( rObjectCID, xModel ); 770*cdf0e10cSrcweir case OBJECTTYPE_DATA_SERIES: 771*cdf0e10cSrcweir return lcl_getFullSeriesName( rObjectCID, xModel ); 772*cdf0e10cSrcweir //case OBJECTTYPE_LEGEND_ENTRY: 773*cdf0e10cSrcweir case OBJECTTYPE_DATA_POINT: 774*cdf0e10cSrcweir case OBJECTTYPE_DATA_LABELS: 775*cdf0e10cSrcweir case OBJECTTYPE_DATA_LABEL: 776*cdf0e10cSrcweir case OBJECTTYPE_DATA_ERRORS: 777*cdf0e10cSrcweir case OBJECTTYPE_DATA_ERRORS_X: 778*cdf0e10cSrcweir case OBJECTTYPE_DATA_ERRORS_Y: 779*cdf0e10cSrcweir case OBJECTTYPE_DATA_ERRORS_Z: 780*cdf0e10cSrcweir case OBJECTTYPE_DATA_CURVE: 781*cdf0e10cSrcweir case OBJECTTYPE_DATA_AVERAGE_LINE: 782*cdf0e10cSrcweir case OBJECTTYPE_DATA_CURVE_EQUATION: 783*cdf0e10cSrcweir { 784*cdf0e10cSrcweir rtl::OUString aRet = lcl_getFullSeriesName( rObjectCID, xModel ); 785*cdf0e10cSrcweir aRet += C2U(" "); 786*cdf0e10cSrcweir if( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL ) 787*cdf0e10cSrcweir { 788*cdf0e10cSrcweir aRet += getName( OBJECTTYPE_DATA_POINT ); 789*cdf0e10cSrcweir sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID ); 790*cdf0e10cSrcweir aRet += C2U(" "); 791*cdf0e10cSrcweir aRet += OUString::valueOf(nPointIndex+1); 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir if( eType == OBJECTTYPE_DATA_LABEL ) 794*cdf0e10cSrcweir { 795*cdf0e10cSrcweir aRet += C2U(" "); 796*cdf0e10cSrcweir aRet += getName( OBJECTTYPE_DATA_LABEL ); 797*cdf0e10cSrcweir } 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir else 800*cdf0e10cSrcweir aRet += getName( eType ); 801*cdf0e10cSrcweir return aRet; 802*cdf0e10cSrcweir } 803*cdf0e10cSrcweir default: 804*cdf0e10cSrcweir break; 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir return getName( eType ); 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir rtl::OUString ObjectNameProvider::getName_ObjectForSeries( 811*cdf0e10cSrcweir ObjectType eObjectType, 812*cdf0e10cSrcweir const rtl::OUString& rSeriesCID, 813*cdf0e10cSrcweir const uno::Reference< chart2::XChartDocument >& xChartDocument ) 814*cdf0e10cSrcweir { 815*cdf0e10cSrcweir uno::Reference< frame::XModel> xChartModel( xChartDocument, uno::UNO_QUERY ); 816*cdf0e10cSrcweir Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rSeriesCID , xChartModel ), uno::UNO_QUERY ); 817*cdf0e10cSrcweir if( xSeries.is() ) 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir OUString aRet = String(SchResId(STR_OBJECT_FOR_SERIES)); 820*cdf0e10cSrcweir replaceParamterInString( aRet, C2U("%OBJECTNAME"), getName( eObjectType, false /*bPlural*/ ) ); 821*cdf0e10cSrcweir replaceParamterInString( aRet, C2U("%SERIESNAME"), lcl_getDataSeriesName( rSeriesCID, xChartModel ) ); 822*cdf0e10cSrcweir return aRet; 823*cdf0e10cSrcweir } 824*cdf0e10cSrcweir else 825*cdf0e10cSrcweir return ObjectNameProvider::getName_ObjectForAllSeries( eObjectType ); 826*cdf0e10cSrcweir } 827*cdf0e10cSrcweir 828*cdf0e10cSrcweir rtl::OUString ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType ) 829*cdf0e10cSrcweir { 830*cdf0e10cSrcweir OUString aRet = String(SchResId(STR_OBJECT_FOR_ALL_SERIES)); 831*cdf0e10cSrcweir replaceParamterInString( aRet, C2U("%OBJECTNAME"), getName( eObjectType, true /*bPlural*/ ) ); 832*cdf0e10cSrcweir return aRet; 833*cdf0e10cSrcweir } 834*cdf0e10cSrcweir 835*cdf0e10cSrcweir //............................................................................. 836*cdf0e10cSrcweir } //namespace chart 837*cdf0e10cSrcweir //............................................................................. 838