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