1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ObjectNameProvider.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "ObjectNameProvider.hxx"
36 #include "Strings.hrc"
38 #include "AxisHelper.hxx"
39 #include "ChartModelHelper.hxx"
40 #include "DiagramHelper.hxx"
41 #include "DataSeriesHelper.hxx"
42 #include "TitleHelper.hxx"
43 #include "AxisIndexDefines.hxx"
44 #include "ExplicitCategoriesProvider.hxx"
45 #include "CommonConverters.hxx"
46 #include "chartview/NumberFormatterWrapper.hxx"
47 #include "RegressionCurveHelper.hxx"
48 #include <rtl/math.hxx>
49 #include <tools/debug.hxx>
50 #include <tools/string.hxx>
52 // #include <svtools/syslocale.hxx>
54 #include <com/sun/star/chart2/XTitle.hpp>
55 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
57 //.............................................................................
60 //.............................................................................
61 using namespace ::com::sun::star
;
62 using namespace ::com::sun::star::chart2
;
63 using ::com::sun::star::uno::Reference
;
64 using ::com::sun::star::uno::Sequence
;
65 using ::com::sun::star::uno::Any
;
71 OUString
lcl_getDataSeriesName( const rtl::OUString
& rObjectCID
, const Reference
< frame::XModel
>& xChartModel
)
75 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
76 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
77 if( xDiagram
.is() && xSeries
.is() )
79 Reference
< XChartType
> xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram
, xSeries
) );
82 aRet
= ::chart::DataSeriesHelper::getDataSeriesLabel(
83 xSeries
, xChartType
->getRoleOfSequenceForSeriesLabel() ) ;
90 void lcl_addText( OUString
& rOut
, const OUString
& rSeparator
, const OUString
& rNext
)
92 if( rOut
.getLength() && rNext
.getLength() )
94 if( rNext
.getLength() )
98 OUString
lcl_getDataPointValueText( const Reference
< XDataSeries
>& xSeries
, sal_Int32 nPointIndex
,
99 const Reference
< XCoordinateSystem
>& xCooSys
,
100 const Reference
< frame::XModel
>& xChartModel
)
105 Reference
<data::XDataSource
> xDataSource(
106 uno::Reference
<data::XDataSource
>( xSeries
, uno::UNO_QUERY
) );
107 if(!xDataSource
.is())
110 Sequence
< Reference
< data::XLabeledDataSequence
> > aDataSequences( xDataSource
->getDataSequences() );
112 rtl::OUString aX
, aY
, aY_Min
, aY_Max
, aY_First
, aY_Last
, a_Size
;
115 uno::Reference
< util::XNumberFormatsSupplier
> xNumberFormatsSupplier( xChartModel
, uno::UNO_QUERY
);
116 NumberFormatterWrapper
aNumberFormatterWrapper( xNumberFormatsSupplier
);
117 sal_Int32 nLabelColor
= 0;//dummy
118 bool bColorChanged
;//dummy
120 for(sal_Int32 nN
= aDataSequences
.getLength();nN
--;)
122 uno::Reference
<data::XDataSequence
> xDataSequence( aDataSequences
[nN
]->getValues());
123 if( !xDataSequence
.is() )
125 Sequence
< Any
> aData( xDataSequence
->getData() );
126 if( nPointIndex
>= aData
.getLength() )
128 uno::Reference
<beans::XPropertySet
> xProp(xDataSequence
, uno::UNO_QUERY
);
133 uno::Any aARole
= xProp
->getPropertyValue( C2U( "Role" ) );
137 if( aRole
.equals(C2U("values-x")) )
139 aData
[nPointIndex
]>>= fValue
;
140 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
141 aX
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
143 else if( aRole
.equals(C2U("values-y")) )
145 aData
[nPointIndex
]>>= fValue
;
146 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
147 aY
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
149 else if( aRole
.equals(C2U("values-first")) )
151 aData
[nPointIndex
]>>= fValue
;
152 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
153 aY_First
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
155 else if( aRole
.equals(C2U("values-min")) )
157 aData
[nPointIndex
]>>= fValue
;
158 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
159 aY_Min
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
161 else if( aRole
.equals(C2U("values-max")) )
163 aData
[nPointIndex
]>>= fValue
;
164 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
165 aY_Max
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
167 else if( aRole
.equals(C2U("values-last")) )
169 aData
[nPointIndex
]>>= fValue
;
170 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
171 aY_Last
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
173 else if( aRole
.equals(C2U("values-size")) )
175 aData
[nPointIndex
]>>= fValue
;
176 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
177 a_Size
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
180 catch( uno::Exception
& e
)
182 ASSERT_EXCEPTION( e
);
187 if( aX
.getLength() == 0 )
189 rtl::OUString aCategory
= ::rtl::OUString( String(SchResId(STR_TIP_CATEGORY_VALUE
)));
191 replaceParamterInString( aCategory
192 , C2U("%CATEGORYVALUE")
193 , ExplicitCategoriesProvider::getCategoryByIndex( xCooSys
, nPointIndex
)
203 OUString
aSeparator(C2U(" "));
205 lcl_addText( aRet
, aSeparator
, aY
);
206 lcl_addText( aRet
, aSeparator
, aY_First
);
207 lcl_addText( aRet
, aSeparator
, aY_Min
);
208 lcl_addText( aRet
, aSeparator
, aY_Max
);
209 lcl_addText( aRet
, aSeparator
, aY_Last
);
210 lcl_addText( aRet
, aSeparator
, a_Size
);
215 } //end anonymous namespace
217 rtl::OUString
ObjectNameProvider::getName( ObjectType eObjectType
, bool bPlural
)
220 switch( eObjectType
)
222 case OBJECTTYPE_PAGE
:
223 aRet
=String(SchResId(STR_OBJECT_PAGE
));
225 case OBJECTTYPE_TITLE
:
228 aRet
=String(SchResId(STR_OBJECT_TITLES
));
230 aRet
=String(SchResId(STR_OBJECT_TITLE
));
233 case OBJECTTYPE_LEGEND
:
234 aRet
=String(SchResId(STR_OBJECT_LEGEND
));
236 case OBJECTTYPE_LEGEND_ENTRY
:
237 aRet
=String(SchResId(STR_OBJECT_LEGEND_SYMBOL
));//@todo change string if we do differenciate symbol and legend entry in future
239 case OBJECTTYPE_DIAGRAM
:
240 aRet
=String(SchResId(STR_OBJECT_DIAGRAM
));
242 case OBJECTTYPE_DIAGRAM_WALL
:
243 aRet
=String(SchResId(STR_OBJECT_DIAGRAM_WALL
));
245 case OBJECTTYPE_DIAGRAM_FLOOR
:
246 aRet
=String(SchResId(STR_OBJECT_DIAGRAM_FLOOR
));
248 case OBJECTTYPE_AXIS
:
251 aRet
=String(SchResId(STR_OBJECT_AXES
));
253 aRet
=String(SchResId(STR_OBJECT_AXIS
));
256 case OBJECTTYPE_AXIS_UNITLABEL
:
257 aRet
=String(SchResId(STR_OBJECT_LABEL
));//@todo maybe a more concrete name
259 case OBJECTTYPE_GRID
:
260 case OBJECTTYPE_SUBGRID
: //maybe todo: different names for subgrids
263 aRet
=String(SchResId(STR_OBJECT_GRIDS
));
265 aRet
=String(SchResId(STR_OBJECT_GRID
));
268 case OBJECTTYPE_DATA_SERIES
:
271 aRet
=String(SchResId(STR_OBJECT_DATASERIES_PLURAL
));
273 aRet
=String(SchResId(STR_OBJECT_DATASERIES
));
276 case OBJECTTYPE_DATA_POINT
:
279 aRet
=String(SchResId(STR_OBJECT_DATAPOINTS
));
281 aRet
=String(SchResId(STR_OBJECT_DATAPOINT
));
284 case OBJECTTYPE_DATA_LABELS
:
285 aRet
=String(SchResId(STR_OBJECT_DATALABELS
));
287 case OBJECTTYPE_DATA_LABEL
:
288 aRet
=String(SchResId(STR_OBJECT_LABEL
));
290 case OBJECTTYPE_DATA_ERRORS
:
291 aRet
=String(SchResId(STR_OBJECT_ERROR_INDICATOR
));//@todo? maybe distinguish plural singular
293 case OBJECTTYPE_DATA_ERRORS_X
:
294 aRet
=String(SchResId(STR_OBJECT_ERROR_INDICATOR
));//@todo? maybe specialize in future
296 case OBJECTTYPE_DATA_ERRORS_Y
:
297 aRet
=String(SchResId(STR_OBJECT_ERROR_INDICATOR
));//@todo? maybe specialize in future
299 case OBJECTTYPE_DATA_ERRORS_Z
:
300 aRet
=String(SchResId(STR_OBJECT_ERROR_INDICATOR
));//@todo? maybe specialize in future
302 case OBJECTTYPE_DATA_AVERAGE_LINE
:
303 aRet
=String(SchResId(STR_OBJECT_AVERAGE_LINE
));
305 case OBJECTTYPE_DATA_CURVE
:
306 aRet
=String(SchResId(STR_OBJECT_CURVE
));
308 case OBJECTTYPE_DATA_STOCK_RANGE
:
309 //aRet=String(SchResId());
311 case OBJECTTYPE_DATA_STOCK_LOSS
:
312 aRet
=String(SchResId(STR_OBJECT_STOCK_LOSS
));
314 case OBJECTTYPE_DATA_STOCK_GAIN
:
315 aRet
=String(SchResId(STR_OBJECT_STOCK_GAIN
));
317 case OBJECTTYPE_DATA_CURVE_EQUATION
:
318 aRet
=String(SchResId(STR_OBJECT_CURVE_EQUATION
));
320 default: //OBJECTTYPE_UNKNOWN
326 rtl::OUString
ObjectNameProvider::getAxisName( const rtl::OUString
& rObjectCID
327 , const uno::Reference
< frame::XModel
>& xChartModel
)
333 Reference
< XAxis
> xAxis(
334 ObjectIdentifier::getObjectPropertySet( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
336 sal_Int32 nDimensionIndex
= AxisHelper::getDimensionIndexOfAxis( xAxis
, ChartModelHelper::findDiagram( xChartModel
) );
338 switch(nDimensionIndex
)
341 aRet
=String(SchResId(STR_OBJECT_AXIS_X
));
344 aRet
=String(SchResId(STR_OBJECT_AXIS_Y
));
347 aRet
=String(SchResId(STR_OBJECT_AXIS_Z
));
350 aRet
=String(SchResId(STR_OBJECT_AXIS
));
358 OUString
ObjectNameProvider::getTitleName( const OUString
& rObjectCID
359 , const Reference
< frame::XModel
>& xChartModel
)
363 Reference
< XTitle
> xTitle(
364 ObjectIdentifier::getObjectPropertySet( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
367 TitleHelper::eTitleType eType
;
368 if( TitleHelper::getTitleType( eType
, xTitle
, xChartModel
) )
372 case TitleHelper::MAIN_TITLE
:
373 aRet
=String(SchResId(STR_OBJECT_TITLE_MAIN
));
375 case TitleHelper::SUB_TITLE
:
376 aRet
=String(SchResId(STR_OBJECT_TITLE_SUB
));
378 case TitleHelper::X_AXIS_TITLE
:
379 aRet
=String(SchResId(STR_OBJECT_TITLE_X_AXIS
));
381 case TitleHelper::Y_AXIS_TITLE
:
382 aRet
=String(SchResId(STR_OBJECT_TITLE_Y_AXIS
));
384 case TitleHelper::Z_AXIS_TITLE
:
385 aRet
=String(SchResId(STR_OBJECT_TITLE_Z_AXIS
));
387 case TitleHelper::SECONDARY_X_AXIS_TITLE
:
388 aRet
=String(SchResId(STR_OBJECT_TITLE_SECONDARY_X_AXIS
));
390 case TitleHelper::SECONDARY_Y_AXIS_TITLE
:
391 aRet
=String(SchResId(STR_OBJECT_TITLE_SECONDARY_Y_AXIS
));
394 DBG_ERROR("unknown title type");
399 if( !aRet
.getLength() )
400 aRet
=String(SchResId(STR_OBJECT_TITLE
));
406 rtl::OUString
ObjectNameProvider::getGridName( const rtl::OUString
& rObjectCID
407 , const uno::Reference
< frame::XModel
>& xChartModel
)
412 sal_Int32 nCooSysIndex
= -1;
413 sal_Int32 nDimensionIndex
= -1;
414 sal_Int32 nAxisIndex
= -1;
415 Reference
< XAxis
> xAxis( ObjectIdentifier::getAxisForCID( rObjectCID
, xChartModel
) );
416 AxisHelper::getIndicesForAxis( xAxis
, ChartModelHelper::findDiagram( xChartModel
)
417 , nCooSysIndex
, nDimensionIndex
, nAxisIndex
);
419 bool bMainGrid
= (ObjectIdentifier::getObjectType( rObjectCID
) == OBJECTTYPE_GRID
);
423 switch(nDimensionIndex
)
426 aRet
=String(SchResId(STR_OBJECT_GRID_MAJOR_X
));
429 aRet
=String(SchResId(STR_OBJECT_GRID_MAJOR_Y
));
432 aRet
=String(SchResId(STR_OBJECT_GRID_MAJOR_Z
));
435 aRet
=String(SchResId(STR_OBJECT_GRID
));
441 switch(nDimensionIndex
)
444 aRet
=String(SchResId(STR_OBJECT_GRID_MINOR_X
));
447 aRet
=String(SchResId(STR_OBJECT_GRID_MINOR_Y
));
450 aRet
=String(SchResId(STR_OBJECT_GRID_MINOR_Z
));
453 aRet
=String(SchResId(STR_OBJECT_GRID
));
460 rtl::OUString
ObjectNameProvider::getHelpText( const rtl::OUString
& rObjectCID
, const Reference
< chart2::XChartDocument
>& xChartDocument
, bool bVerbose
)
462 return getHelpText( rObjectCID
, Reference
< frame::XModel
>( xChartDocument
, uno::UNO_QUERY
), bVerbose
);
465 rtl::OUString
ObjectNameProvider::getHelpText( const rtl::OUString
& rObjectCID
, const Reference
< frame::XModel
>& xChartModel
, bool bVerbose
)
468 ObjectType
eObjectType( ObjectIdentifier::getObjectType(rObjectCID
) );
469 if( OBJECTTYPE_AXIS
== eObjectType
)
471 aRet
=ObjectNameProvider::getAxisName( rObjectCID
, xChartModel
);
473 else if( OBJECTTYPE_GRID
== eObjectType
474 || OBJECTTYPE_SUBGRID
== eObjectType
)
476 aRet
=ObjectNameProvider::getGridName( rObjectCID
, xChartModel
);
478 else if( OBJECTTYPE_TITLE
== eObjectType
)
480 aRet
=ObjectNameProvider::getTitleName( rObjectCID
, xChartModel
);
482 else if( OBJECTTYPE_DATA_SERIES
== eObjectType
)
484 aRet
=String(SchResId(STR_TIP_DATASERIES
));
486 OUString
aWildcard( C2U("%SERIESNAME") );
487 sal_Int32 nIndex
= aRet
.indexOf( aWildcard
);
489 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), lcl_getDataSeriesName( rObjectCID
, xChartModel
) );
491 else if( OBJECTTYPE_DATA_POINT
== eObjectType
)
495 OUString
aNewLine(C2U("\n"));
497 aRet
=String(SchResId(STR_TIP_DATAPOINT_INDEX
));
499 aRet
+=String(SchResId(STR_TIP_DATASERIES
));
501 aRet
+=String(SchResId(STR_TIP_DATAPOINT_VALUES
));
504 aRet
=String(SchResId(STR_TIP_DATAPOINT
));
506 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
507 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
508 if( xDiagram
.is() && xSeries
.is() )
510 sal_Int32
nPointIndex( ObjectIdentifier::getParticleID(rObjectCID
).toInt32() );
512 //replace data point index
513 sal_Int32 nIndex
= -1;
514 OUString
aWildcard( C2U("%POINTNUMBER") );
515 nIndex
= aRet
.indexOf( aWildcard
);
518 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), OUString::valueOf(nPointIndex
+1) );
521 //replace data series index
522 aWildcard
= C2U("%SERIESNUMBER");
523 nIndex
= aRet
.indexOf( aWildcard
);
526 ::std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVector(
527 DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
528 sal_Int32 nSeriesIndex
= -1;
529 for( nSeriesIndex
=aSeriesVector
.size();nSeriesIndex
--;)
531 if( aSeriesVector
[nSeriesIndex
] == xSeries
)
537 OUString
aReplacement( OUString::valueOf(nSeriesIndex
+1) );
538 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), aReplacement
);
541 //replace point values
542 aWildcard
= C2U("%POINTVALUES");
543 nIndex
= aRet
.indexOf( aWildcard
);
545 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), lcl_getDataPointValueText(
546 xSeries
,nPointIndex
, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries
, xDiagram
), xChartModel
) );
548 //replace series name
549 aWildcard
= C2U("%SERIESNAME");
550 nIndex
= aRet
.indexOf( aWildcard
);
552 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), lcl_getDataSeriesName( rObjectCID
, xChartModel
) );
556 else if( OBJECTTYPE_DIAGRAM == eObjectType )
558 //todo different names for different diagram types ???
559 //or different names for series of diferent charttypes
562 else if( OBJECTTYPE_DATA_CURVE
== eObjectType
)
566 aRet
= String( SchResId( STR_OBJECT_CURVE_WITH_PARAMETERS
));
567 Reference
< chart2::XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
));
568 Reference
< chart2::XRegressionCurveContainer
> xCurveCnt( xSeries
, uno::UNO_QUERY
);
571 Reference
< chart2::XRegressionCurve
> xCurve( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt
));
576 Reference
< chart2::XRegressionCurveCalculator
> xCalculator( xCurve
->getCalculator(), uno::UNO_QUERY_THROW
);
577 RegressionCurveHelper::initializeCurveCalculator( xCalculator
, xSeries
, xChartModel
);
580 sal_Int32 nIndex
= -1;
581 OUString
aWildcard( C2U("%FORMULA") );
582 nIndex
= aRet
.indexOf( aWildcard
);
584 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), xCalculator
->getRepresentation());
587 aWildcard
= C2U("%RSQUARED");
588 nIndex
= aRet
.indexOf( aWildcard
);
591 sal_Unicode
aDecimalSep( '.' );
592 //@todo: enable this code when a localized decimal
593 //separator is also available for the formula
594 // SvtSysLocale aSysLocale;
595 // OUString aSep( aSysLocale.GetLocaleData().getNumDecimalSep());
596 // if( aSep.getLength() == 1 )
597 // aDecimalSep = aSep.toChar();
598 double fR( xCalculator
->getCorrelationCoefficient());
599 aRet
= aRet
.replaceAt(
600 nIndex
, aWildcard
.getLength(),
601 ::rtl::math::doubleToUString(
602 fR
*fR
, rtl_math_StringFormat_G
, 4, aDecimalSep
, true ));
605 catch( const uno::Exception
& ex
)
607 ASSERT_EXCEPTION( ex
);
615 aRet
= ObjectNameProvider::getName( eObjectType
, false );
618 else if( OBJECTTYPE_DATA_AVERAGE_LINE
== eObjectType
)
622 aRet
= String( SchResId( STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS
));
623 Reference
< chart2::XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
));
624 Reference
< chart2::XRegressionCurveContainer
> xCurveCnt( xSeries
, uno::UNO_QUERY
);
627 Reference
< chart2::XRegressionCurve
> xCurve( RegressionCurveHelper::getMeanValueLine( xCurveCnt
));
632 Reference
< chart2::XRegressionCurveCalculator
> xCalculator( xCurve
->getCalculator(), uno::UNO_QUERY_THROW
);
633 RegressionCurveHelper::initializeCurveCalculator( xCalculator
, xSeries
, xChartModel
);
635 sal_Unicode
aDecimalSep( '.' );
636 // replace average value
637 // SvtSysLocale aSysLocale;
638 // OUString aSep( aSysLocale.GetLocaleData().getNumDecimalSep());
639 // if( aSep.getLength() == 1 )
640 // aDecimalSep = aSep.toChar();
642 sal_Int32 nIndex
= -1;
643 OUString
aWildcard( C2U("%AVERAGE_VALUE") );
644 nIndex
= aRet
.indexOf( aWildcard
);
645 // as the curve is constant, the value at any x-value is ok
648 const double fMeanValue( xCalculator
->getCurveValue( 0.0 ));
649 aRet
= aRet
.replaceAt(
650 nIndex
, aWildcard
.getLength(),
651 ::rtl::math::doubleToUString(
652 fMeanValue
, rtl_math_StringFormat_G
, 4, aDecimalSep
, true ));
655 // replace standard deviation
656 aWildcard
= C2U("%STD_DEVIATION");
657 nIndex
= aRet
.indexOf( aWildcard
);
660 const double fStdDev( xCalculator
->getCorrelationCoefficient());
661 aRet
= aRet
.replaceAt(
662 nIndex
, aWildcard
.getLength(),
663 ::rtl::math::doubleToUString(
664 fStdDev
, rtl_math_StringFormat_G
, 4, aDecimalSep
, true ));
667 catch( const uno::Exception
& ex
)
669 ASSERT_EXCEPTION( ex
);
677 aRet
= ObjectNameProvider::getName( eObjectType
, false );
682 aRet
= ObjectNameProvider::getName( eObjectType
, false );
688 rtl::OUString
ObjectNameProvider::getSelectedObjectText( const rtl::OUString
& rObjectCID
, const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartDocument
>& xChartDocument
)
691 ObjectType
eObjectType( ObjectIdentifier::getObjectType(rObjectCID
) );
692 Reference
< frame::XModel
> xChartModel( xChartDocument
, uno::UNO_QUERY
);
694 if( OBJECTTYPE_DATA_POINT
== eObjectType
)
696 aRet
= String( SchResId( STR_STATUS_DATAPOINT_MARKED
));
698 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
699 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
700 if( xDiagram
.is() && xSeries
.is() )
702 sal_Int32
nPointIndex( ObjectIdentifier::getParticleID(rObjectCID
).toInt32() );
704 // replace data point index
705 replaceParamterInString( aRet
, C2U("%POINTNUMBER"), OUString::valueOf( nPointIndex
+ 1 ));
707 // replace data series index
709 ::std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVector(
710 DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
711 sal_Int32 nSeriesIndex
= -1;
712 for( nSeriesIndex
=aSeriesVector
.size();nSeriesIndex
--;)
714 if( aSeriesVector
[nSeriesIndex
] == xSeries
)
717 replaceParamterInString( aRet
, C2U("%SERIESNUMBER"), OUString::valueOf( nSeriesIndex
+ 1 ) );
720 // replace point value
721 replaceParamterInString( aRet
, C2U("%POINTVALUES"), lcl_getDataPointValueText(
722 xSeries
, nPointIndex
, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries
, xDiagram
), xChartModel
) );
727 // use the verbose text including the formula for trend lines
728 const bool bVerbose( OBJECTTYPE_DATA_CURVE
== eObjectType
|| OBJECTTYPE_DATA_AVERAGE_LINE
== eObjectType
);
729 const OUString
aHelpText( getHelpText( rObjectCID
, xChartModel
, bVerbose
));
730 if( aHelpText
.getLength())
732 aRet
= String( SchResId( STR_STATUS_OBJECT_MARKED
));
733 replaceParamterInString( aRet
, C2U("%OBJECTNAME"), aHelpText
);
742 rtl::OUString
ObjectNameProvider::getNameForCID(
743 const rtl::OUString
& rObjectCID
,
744 const uno::Reference
< chart2::XChartDocument
>& xChartDocument
)
746 ObjectType
eType( ObjectIdentifier::getObjectType( rObjectCID
));
747 Reference
< frame::XModel
> xModel( xChartDocument
, uno::UNO_QUERY
);
751 case OBJECTTYPE_AXIS
:
752 return getAxisName( rObjectCID
, xModel
);
753 case OBJECTTYPE_TITLE
:
754 return getTitleName( rObjectCID
, xModel
);
755 case OBJECTTYPE_GRID
:
756 return getGridName( rObjectCID
, xModel
);
761 return getName( eType
);
765 //.............................................................................
767 //.............................................................................