1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "ObjectNameProvider.hxx"
32 #include "Strings.hrc"
34 #include "AxisHelper.hxx"
35 #include "ChartModelHelper.hxx"
36 #include "DiagramHelper.hxx"
37 #include "DataSeriesHelper.hxx"
38 #include "TitleHelper.hxx"
39 #include "AxisIndexDefines.hxx"
40 #include "ExplicitCategoriesProvider.hxx"
41 #include "CommonConverters.hxx"
42 #include "NumberFormatterWrapper.hxx"
43 #include "RegressionCurveHelper.hxx"
44 #include <rtl/math.hxx>
45 #include <tools/string.hxx>
47 #include <com/sun/star/chart2/XTitle.hpp>
48 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
50 //.............................................................................
53 //.............................................................................
54 using namespace ::com::sun::star
;
55 using namespace ::com::sun::star::chart2
;
56 using ::com::sun::star::uno::Reference
;
57 using ::com::sun::star::uno::Sequence
;
58 using ::com::sun::star::uno::Any
;
64 OUString
lcl_getDataSeriesName( const rtl::OUString
& rObjectCID
, const Reference
< frame::XModel
>& xChartModel
)
68 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
69 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
70 if( xDiagram
.is() && xSeries
.is() )
72 Reference
< XChartType
> xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram
, xSeries
) );
75 aRet
= ::chart::DataSeriesHelper::getDataSeriesLabel(
76 xSeries
, xChartType
->getRoleOfSequenceForSeriesLabel() ) ;
83 OUString
lcl_getFullSeriesName( const rtl::OUString
& rObjectCID
, const Reference
< frame::XModel
>& xChartModel
)
85 OUString aRet
= String(SchResId(STR_TIP_DATASERIES
));
86 OUString
aWildcard( C2U("%SERIESNAME") );
87 sal_Int32 nIndex
= aRet
.indexOf( aWildcard
);
89 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), lcl_getDataSeriesName( rObjectCID
, xChartModel
) );
93 void lcl_addText( OUString
& rOut
, const OUString
& rSeparator
, const OUString
& rNext
)
95 if( !(rOut
.isEmpty() || rNext
.isEmpty()) )
97 if( !rNext
.isEmpty() )
101 OUString
lcl_getDataPointValueText( const Reference
< XDataSeries
>& xSeries
, sal_Int32 nPointIndex
,
102 const Reference
< XCoordinateSystem
>& xCooSys
,
103 const Reference
< frame::XModel
>& xChartModel
)
108 Reference
<data::XDataSource
> xDataSource(
109 uno::Reference
<data::XDataSource
>( xSeries
, uno::UNO_QUERY
) );
110 if(!xDataSource
.is())
113 Sequence
< Reference
< data::XLabeledDataSequence
> > aDataSequences( xDataSource
->getDataSequences() );
115 rtl::OUString aX
, aY
, aY_Min
, aY_Max
, aY_First
, aY_Last
, a_Size
;
118 uno::Reference
< util::XNumberFormatsSupplier
> xNumberFormatsSupplier( xChartModel
, uno::UNO_QUERY
);
119 NumberFormatterWrapper
aNumberFormatterWrapper( xNumberFormatsSupplier
);
120 sal_Int32 nLabelColor
= 0;//dummy
121 bool bColorChanged
;//dummy
123 for(sal_Int32 nN
= aDataSequences
.getLength();nN
--;)
125 uno::Reference
<data::XDataSequence
> xDataSequence( aDataSequences
[nN
]->getValues());
126 if( !xDataSequence
.is() )
128 Sequence
< Any
> aData( xDataSequence
->getData() );
129 if( nPointIndex
>= aData
.getLength() )
131 uno::Reference
<beans::XPropertySet
> xProp(xDataSequence
, uno::UNO_QUERY
);
136 uno::Any aARole
= xProp
->getPropertyValue( C2U( "Role" ) );
140 if( aRole
.equals(C2U("values-x")) )
142 aData
[nPointIndex
]>>= fValue
;
143 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
144 aX
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
146 else if( aRole
.equals(C2U("values-y")) )
148 aData
[nPointIndex
]>>= fValue
;
149 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
150 aY
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
152 else if( aRole
.equals(C2U("values-first")) )
154 aData
[nPointIndex
]>>= fValue
;
155 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
156 aY_First
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
158 else if( aRole
.equals(C2U("values-min")) )
160 aData
[nPointIndex
]>>= fValue
;
161 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
162 aY_Min
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
164 else if( aRole
.equals(C2U("values-max")) )
166 aData
[nPointIndex
]>>= fValue
;
167 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
168 aY_Max
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
170 else if( aRole
.equals(C2U("values-last")) )
172 aData
[nPointIndex
]>>= fValue
;
173 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
174 aY_Last
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
176 else if( aRole
.equals(C2U("values-size")) )
178 aData
[nPointIndex
]>>= fValue
;
179 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
180 a_Size
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
183 catch( const uno::Exception
& e
)
185 ASSERT_EXCEPTION( e
);
192 aRet
= ExplicitCategoriesProvider::getCategoryByIndex( xCooSys
, xChartModel
, nPointIndex
);
199 OUString
aSeparator(C2U(" "));
201 lcl_addText( aRet
, aSeparator
, aY
);
202 lcl_addText( aRet
, aSeparator
, aY_First
);
203 lcl_addText( aRet
, aSeparator
, aY_Min
);
204 lcl_addText( aRet
, aSeparator
, aY_Max
);
205 lcl_addText( aRet
, aSeparator
, aY_Last
);
206 lcl_addText( aRet
, aSeparator
, a_Size
);
211 } //end anonymous namespace
213 rtl::OUString
ObjectNameProvider::getName( ObjectType eObjectType
, bool bPlural
)
216 switch( eObjectType
)
218 case OBJECTTYPE_PAGE
:
219 aRet
=String(SchResId(STR_OBJECT_PAGE
));
221 case OBJECTTYPE_TITLE
:
224 aRet
=String(SchResId(STR_OBJECT_TITLES
));
226 aRet
=String(SchResId(STR_OBJECT_TITLE
));
229 case OBJECTTYPE_LEGEND
:
230 aRet
=String(SchResId(STR_OBJECT_LEGEND
));
232 case OBJECTTYPE_LEGEND_ENTRY
:
233 aRet
=String(SchResId(STR_OBJECT_LEGEND_SYMBOL
));//@todo change string if we do differenciate symbol and legend entry in future
235 case OBJECTTYPE_DIAGRAM
:
236 aRet
=String(SchResId(STR_OBJECT_DIAGRAM
));
238 case OBJECTTYPE_DIAGRAM_WALL
:
239 aRet
=String(SchResId(STR_OBJECT_DIAGRAM_WALL
));
241 case OBJECTTYPE_DIAGRAM_FLOOR
:
242 aRet
=String(SchResId(STR_OBJECT_DIAGRAM_FLOOR
));
244 case OBJECTTYPE_AXIS
:
247 aRet
=String(SchResId(STR_OBJECT_AXES
));
249 aRet
=String(SchResId(STR_OBJECT_AXIS
));
252 case OBJECTTYPE_AXIS_UNITLABEL
:
253 aRet
=String(SchResId(STR_OBJECT_LABEL
));//@todo maybe a more concrete name
255 case OBJECTTYPE_GRID
:
256 case OBJECTTYPE_SUBGRID
: //maybe todo: different names for subgrids
259 aRet
=String(SchResId(STR_OBJECT_GRIDS
));
261 aRet
=String(SchResId(STR_OBJECT_GRID
));
264 case OBJECTTYPE_DATA_SERIES
:
267 aRet
=String(SchResId(STR_OBJECT_DATASERIES_PLURAL
));
269 aRet
=String(SchResId(STR_OBJECT_DATASERIES
));
272 case OBJECTTYPE_DATA_POINT
:
275 aRet
=String(SchResId(STR_OBJECT_DATAPOINTS
));
277 aRet
=String(SchResId(STR_OBJECT_DATAPOINT
));
280 case OBJECTTYPE_DATA_LABELS
:
281 aRet
=String(SchResId(STR_OBJECT_DATALABELS
));
283 case OBJECTTYPE_DATA_LABEL
:
284 aRet
=String(SchResId(STR_OBJECT_LABEL
));
286 case OBJECTTYPE_DATA_ERRORS_X
:
287 aRet
=String(SchResId(STR_OBJECT_ERROR_BARS_X
));
289 case OBJECTTYPE_DATA_ERRORS_Y
:
290 aRet
=String(SchResId(STR_OBJECT_ERROR_BARS_Y
));
292 case OBJECTTYPE_DATA_ERRORS_Z
:
293 aRet
=String(SchResId(STR_OBJECT_ERROR_BARS_Z
));
295 case OBJECTTYPE_DATA_AVERAGE_LINE
:
296 aRet
=String(SchResId(STR_OBJECT_AVERAGE_LINE
));
298 case OBJECTTYPE_DATA_CURVE
:
301 aRet
=String(SchResId(STR_OBJECT_CURVES
));
303 aRet
=String(SchResId(STR_OBJECT_CURVE
));
306 case OBJECTTYPE_DATA_STOCK_RANGE
:
308 case OBJECTTYPE_DATA_STOCK_LOSS
:
309 aRet
=String(SchResId(STR_OBJECT_STOCK_LOSS
));
311 case OBJECTTYPE_DATA_STOCK_GAIN
:
312 aRet
=String(SchResId(STR_OBJECT_STOCK_GAIN
));
314 case OBJECTTYPE_DATA_CURVE_EQUATION
:
315 aRet
=String(SchResId(STR_OBJECT_CURVE_EQUATION
));
317 default: //OBJECTTYPE_UNKNOWN
323 rtl::OUString
ObjectNameProvider::getAxisName( const rtl::OUString
& rObjectCID
324 , const uno::Reference
< frame::XModel
>& xChartModel
)
330 Reference
< XAxis
> xAxis(
331 ObjectIdentifier::getObjectPropertySet( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
333 sal_Int32 nCooSysIndex
= 0;
334 sal_Int32 nDimensionIndex
= 0;
335 sal_Int32 nAxisIndex
= 0;
336 AxisHelper::getIndicesForAxis( xAxis
, ChartModelHelper::findDiagram( xChartModel
), nCooSysIndex
, nDimensionIndex
, nAxisIndex
);
338 switch(nDimensionIndex
)
341 if( nAxisIndex
== 0 )
342 aRet
=String(SchResId(STR_OBJECT_AXIS_X
));
344 aRet
=String(SchResId(STR_OBJECT_SECONDARY_X_AXIS
));
347 if( nAxisIndex
== 0 )
348 aRet
=String(SchResId(STR_OBJECT_AXIS_Y
));
350 aRet
=String(SchResId(STR_OBJECT_SECONDARY_Y_AXIS
));
353 aRet
=String(SchResId(STR_OBJECT_AXIS_Z
));
356 aRet
=String(SchResId(STR_OBJECT_AXIS
));
363 OUString
ObjectNameProvider::getTitleNameByType( TitleHelper::eTitleType eType
)
369 case TitleHelper::MAIN_TITLE
:
370 aRet
=String(SchResId(STR_OBJECT_TITLE_MAIN
));
372 case TitleHelper::SUB_TITLE
:
373 aRet
=String(SchResId(STR_OBJECT_TITLE_SUB
));
375 case TitleHelper::X_AXIS_TITLE
:
376 aRet
=String(SchResId(STR_OBJECT_TITLE_X_AXIS
));
378 case TitleHelper::Y_AXIS_TITLE
:
379 aRet
=String(SchResId(STR_OBJECT_TITLE_Y_AXIS
));
381 case TitleHelper::Z_AXIS_TITLE
:
382 aRet
=String(SchResId(STR_OBJECT_TITLE_Z_AXIS
));
384 case TitleHelper::SECONDARY_X_AXIS_TITLE
:
385 aRet
=String(SchResId(STR_OBJECT_TITLE_SECONDARY_X_AXIS
));
387 case TitleHelper::SECONDARY_Y_AXIS_TITLE
:
388 aRet
=String(SchResId(STR_OBJECT_TITLE_SECONDARY_Y_AXIS
));
391 OSL_FAIL("unknown title type");
396 aRet
=String(SchResId(STR_OBJECT_TITLE
));
401 OUString
ObjectNameProvider::getTitleName( const OUString
& rObjectCID
402 , const Reference
< frame::XModel
>& xChartModel
)
406 Reference
< XTitle
> xTitle(
407 ObjectIdentifier::getObjectPropertySet( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
410 TitleHelper::eTitleType eType
;
411 if( TitleHelper::getTitleType( eType
, xTitle
, xChartModel
) )
412 aRet
= ObjectNameProvider::getTitleNameByType( eType
);
415 aRet
=String(SchResId(STR_OBJECT_TITLE
));
420 rtl::OUString
ObjectNameProvider::getGridName( const rtl::OUString
& rObjectCID
421 , const uno::Reference
< frame::XModel
>& xChartModel
)
426 sal_Int32 nCooSysIndex
= -1;
427 sal_Int32 nDimensionIndex
= -1;
428 sal_Int32 nAxisIndex
= -1;
429 Reference
< XAxis
> xAxis( ObjectIdentifier::getAxisForCID( rObjectCID
, xChartModel
) );
430 AxisHelper::getIndicesForAxis( xAxis
, ChartModelHelper::findDiagram( xChartModel
)
431 , nCooSysIndex
, nDimensionIndex
, nAxisIndex
);
433 bool bMainGrid
= (ObjectIdentifier::getObjectType( rObjectCID
) == OBJECTTYPE_GRID
);
437 switch(nDimensionIndex
)
440 aRet
=String(SchResId(STR_OBJECT_GRID_MAJOR_X
));
443 aRet
=String(SchResId(STR_OBJECT_GRID_MAJOR_Y
));
446 aRet
=String(SchResId(STR_OBJECT_GRID_MAJOR_Z
));
449 aRet
=String(SchResId(STR_OBJECT_GRID
));
455 switch(nDimensionIndex
)
458 aRet
=String(SchResId(STR_OBJECT_GRID_MINOR_X
));
461 aRet
=String(SchResId(STR_OBJECT_GRID_MINOR_Y
));
464 aRet
=String(SchResId(STR_OBJECT_GRID_MINOR_Z
));
467 aRet
=String(SchResId(STR_OBJECT_GRID
));
474 rtl::OUString
ObjectNameProvider::getHelpText( const rtl::OUString
& rObjectCID
, const Reference
< chart2::XChartDocument
>& xChartDocument
, bool bVerbose
)
476 return getHelpText( rObjectCID
, Reference
< frame::XModel
>( xChartDocument
, uno::UNO_QUERY
), bVerbose
);
479 rtl::OUString
ObjectNameProvider::getHelpText( const rtl::OUString
& rObjectCID
, const Reference
< frame::XModel
>& xChartModel
, bool bVerbose
)
482 ObjectType
eObjectType( ObjectIdentifier::getObjectType(rObjectCID
) );
483 if( OBJECTTYPE_AXIS
== eObjectType
)
485 aRet
=ObjectNameProvider::getAxisName( rObjectCID
, xChartModel
);
487 else if( OBJECTTYPE_GRID
== eObjectType
488 || OBJECTTYPE_SUBGRID
== eObjectType
)
490 aRet
=ObjectNameProvider::getGridName( rObjectCID
, xChartModel
);
492 else if( OBJECTTYPE_TITLE
== eObjectType
)
494 aRet
=ObjectNameProvider::getTitleName( rObjectCID
, xChartModel
);
496 else if( OBJECTTYPE_DATA_SERIES
== eObjectType
)
498 aRet
= lcl_getFullSeriesName( rObjectCID
, xChartModel
);
500 else if( OBJECTTYPE_DATA_POINT
== eObjectType
)
504 OUString
aNewLine(C2U("\n"));
506 aRet
=String(SchResId(STR_TIP_DATAPOINT_INDEX
));
508 aRet
+=String(SchResId(STR_TIP_DATASERIES
));
510 aRet
+=String(SchResId(STR_TIP_DATAPOINT_VALUES
));
513 aRet
=String(SchResId(STR_TIP_DATAPOINT
));
515 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
516 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
517 if( xDiagram
.is() && xSeries
.is() )
519 sal_Int32
nPointIndex( ObjectIdentifier::getParticleID(rObjectCID
).toInt32() );
521 //replace data point index
522 sal_Int32 nIndex
= -1;
523 OUString
aWildcard( C2U("%POINTNUMBER") );
524 nIndex
= aRet
.indexOf( aWildcard
);
527 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), OUString::valueOf(nPointIndex
+1) );
530 //replace data series index
531 aWildcard
= C2U("%SERIESNUMBER");
532 nIndex
= aRet
.indexOf( aWildcard
);
535 ::std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVector(
536 DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
537 sal_Int32 nSeriesIndex
= -1;
538 for( nSeriesIndex
=aSeriesVector
.size();nSeriesIndex
--;)
540 if( aSeriesVector
[nSeriesIndex
] == xSeries
)
546 OUString
aReplacement( OUString::valueOf(nSeriesIndex
+1) );
547 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), aReplacement
);
550 //replace point values
551 aWildcard
= C2U("%POINTVALUES");
552 nIndex
= aRet
.indexOf( aWildcard
);
554 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), lcl_getDataPointValueText(
555 xSeries
,nPointIndex
, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries
, xDiagram
), xChartModel
) );
557 //replace series name
558 aWildcard
= C2U("%SERIESNAME");
559 nIndex
= aRet
.indexOf( aWildcard
);
561 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), lcl_getDataSeriesName( rObjectCID
, xChartModel
) );
564 else if( OBJECTTYPE_DATA_CURVE
== eObjectType
)
568 aRet
= String( SchResId( STR_OBJECT_CURVE_WITH_PARAMETERS
));
569 Reference
< chart2::XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
));
570 Reference
< chart2::XRegressionCurveContainer
> xCurveCnt( xSeries
, uno::UNO_QUERY
);
573 Reference
< chart2::XRegressionCurve
> xCurve( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt
));
578 Reference
< chart2::XRegressionCurveCalculator
> xCalculator( xCurve
->getCalculator(), uno::UNO_QUERY_THROW
);
579 RegressionCurveHelper::initializeCurveCalculator( xCalculator
, xSeries
, xChartModel
);
582 sal_Int32 nIndex
= -1;
583 OUString
aWildcard( C2U("%FORMULA") );
584 nIndex
= aRet
.indexOf( aWildcard
);
586 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), xCalculator
->getRepresentation());
589 aWildcard
= C2U("%RSQUARED");
590 nIndex
= aRet
.indexOf( aWildcard
);
593 sal_Unicode
aDecimalSep( '.' );
594 double fR( xCalculator
->getCorrelationCoefficient());
595 aRet
= aRet
.replaceAt(
596 nIndex
, aWildcard
.getLength(),
597 ::rtl::math::doubleToUString(
598 fR
*fR
, rtl_math_StringFormat_G
, 4, aDecimalSep
, true ));
601 catch( const uno::Exception
& ex
)
603 ASSERT_EXCEPTION( ex
);
611 aRet
= ObjectNameProvider::getName( eObjectType
, false );
614 else if( OBJECTTYPE_DATA_AVERAGE_LINE
== eObjectType
)
618 aRet
= String( SchResId( STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS
));
619 Reference
< chart2::XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
));
620 Reference
< chart2::XRegressionCurveContainer
> xCurveCnt( xSeries
, uno::UNO_QUERY
);
623 Reference
< chart2::XRegressionCurve
> xCurve( RegressionCurveHelper::getMeanValueLine( xCurveCnt
));
628 Reference
< chart2::XRegressionCurveCalculator
> xCalculator( xCurve
->getCalculator(), uno::UNO_QUERY_THROW
);
629 RegressionCurveHelper::initializeCurveCalculator( xCalculator
, xSeries
, xChartModel
);
631 sal_Unicode
aDecimalSep( '.' );
633 sal_Int32 nIndex
= -1;
634 OUString
aWildcard( C2U("%AVERAGE_VALUE") );
635 nIndex
= aRet
.indexOf( aWildcard
);
636 // as the curve is constant, the value at any x-value is ok
639 const double fMeanValue( xCalculator
->getCurveValue( 0.0 ));
640 aRet
= aRet
.replaceAt(
641 nIndex
, aWildcard
.getLength(),
642 ::rtl::math::doubleToUString(
643 fMeanValue
, rtl_math_StringFormat_G
, 4, aDecimalSep
, true ));
646 // replace standard deviation
647 aWildcard
= C2U("%STD_DEVIATION");
648 nIndex
= aRet
.indexOf( aWildcard
);
651 const double fStdDev( xCalculator
->getCorrelationCoefficient());
652 aRet
= aRet
.replaceAt(
653 nIndex
, aWildcard
.getLength(),
654 ::rtl::math::doubleToUString(
655 fStdDev
, rtl_math_StringFormat_G
, 4, aDecimalSep
, true ));
658 catch( const uno::Exception
& ex
)
660 ASSERT_EXCEPTION( ex
);
668 aRet
= ObjectNameProvider::getName( eObjectType
, false );
673 aRet
= ObjectNameProvider::getName( eObjectType
, false );
678 rtl::OUString
ObjectNameProvider::getSelectedObjectText( const rtl::OUString
& rObjectCID
, const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartDocument
>& xChartDocument
)
681 ObjectType
eObjectType( ObjectIdentifier::getObjectType(rObjectCID
) );
682 Reference
< frame::XModel
> xChartModel( xChartDocument
, uno::UNO_QUERY
);
684 if( OBJECTTYPE_DATA_POINT
== eObjectType
)
686 aRet
= String( SchResId( STR_STATUS_DATAPOINT_MARKED
));
688 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
689 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
690 if( xDiagram
.is() && xSeries
.is() )
692 sal_Int32
nPointIndex( ObjectIdentifier::getParticleID(rObjectCID
).toInt32() );
694 // replace data point index
695 replaceParamterInString( aRet
, C2U("%POINTNUMBER"), OUString::valueOf( nPointIndex
+ 1 ));
697 // replace data series index
699 ::std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVector(
700 DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
701 sal_Int32 nSeriesIndex
= -1;
702 for( nSeriesIndex
=aSeriesVector
.size();nSeriesIndex
--;)
704 if( aSeriesVector
[nSeriesIndex
] == xSeries
)
707 replaceParamterInString( aRet
, C2U("%SERIESNUMBER"), OUString::valueOf( nSeriesIndex
+ 1 ) );
710 // replace point value
711 replaceParamterInString( aRet
, C2U("%POINTVALUES"), lcl_getDataPointValueText(
712 xSeries
, nPointIndex
, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries
, xDiagram
), xChartModel
) );
717 // use the verbose text including the formula for trend lines
718 const bool bVerbose( OBJECTTYPE_DATA_CURVE
== eObjectType
|| OBJECTTYPE_DATA_AVERAGE_LINE
== eObjectType
);
719 const OUString
aHelpText( getHelpText( rObjectCID
, xChartModel
, bVerbose
));
720 if( !aHelpText
.isEmpty())
722 aRet
= String( SchResId( STR_STATUS_OBJECT_MARKED
));
723 replaceParamterInString( aRet
, C2U("%OBJECTNAME"), aHelpText
);
731 rtl::OUString
ObjectNameProvider::getNameForCID(
732 const rtl::OUString
& rObjectCID
,
733 const uno::Reference
< chart2::XChartDocument
>& xChartDocument
)
735 ObjectType
eType( ObjectIdentifier::getObjectType( rObjectCID
));
736 Reference
< frame::XModel
> xModel( xChartDocument
, uno::UNO_QUERY
);
740 case OBJECTTYPE_AXIS
:
741 return getAxisName( rObjectCID
, xModel
);
742 case OBJECTTYPE_TITLE
:
743 return getTitleName( rObjectCID
, xModel
);
744 case OBJECTTYPE_GRID
:
745 case OBJECTTYPE_SUBGRID
:
746 return getGridName( rObjectCID
, xModel
);
747 case OBJECTTYPE_DATA_SERIES
:
748 return lcl_getFullSeriesName( rObjectCID
, xModel
);
749 case OBJECTTYPE_DATA_POINT
:
750 case OBJECTTYPE_DATA_LABELS
:
751 case OBJECTTYPE_DATA_LABEL
:
752 case OBJECTTYPE_DATA_ERRORS_X
:
753 case OBJECTTYPE_DATA_ERRORS_Y
:
754 case OBJECTTYPE_DATA_ERRORS_Z
:
755 case OBJECTTYPE_DATA_CURVE
:
756 case OBJECTTYPE_DATA_AVERAGE_LINE
:
757 case OBJECTTYPE_DATA_CURVE_EQUATION
:
759 rtl::OUString aRet
= lcl_getFullSeriesName( rObjectCID
, xModel
);
761 if( eType
== OBJECTTYPE_DATA_POINT
|| eType
== OBJECTTYPE_DATA_LABEL
)
763 aRet
+= getName( OBJECTTYPE_DATA_POINT
);
764 sal_Int32 nPointIndex
= ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID
);
766 aRet
+= OUString::valueOf(nPointIndex
+1);
768 if( eType
== OBJECTTYPE_DATA_LABEL
)
771 aRet
+= getName( OBJECTTYPE_DATA_LABEL
);
775 aRet
+= getName( eType
);
782 return getName( eType
);
785 rtl::OUString
ObjectNameProvider::getName_ObjectForSeries(
786 ObjectType eObjectType
,
787 const rtl::OUString
& rSeriesCID
,
788 const uno::Reference
< chart2::XChartDocument
>& xChartDocument
)
790 uno::Reference
< frame::XModel
> xChartModel( xChartDocument
, uno::UNO_QUERY
);
791 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rSeriesCID
, xChartModel
), uno::UNO_QUERY
);
794 OUString aRet
= String(SchResId(STR_OBJECT_FOR_SERIES
));
795 replaceParamterInString( aRet
, C2U("%OBJECTNAME"), getName( eObjectType
, false /*bPlural*/ ) );
796 replaceParamterInString( aRet
, C2U("%SERIESNAME"), lcl_getDataSeriesName( rSeriesCID
, xChartModel
) );
800 return ObjectNameProvider::getName_ObjectForAllSeries( eObjectType
);
803 rtl::OUString
ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType
)
805 OUString aRet
= String(SchResId(STR_OBJECT_FOR_ALL_SERIES
));
806 replaceParamterInString( aRet
, C2U("%OBJECTNAME"), getName( eObjectType
, true /*bPlural*/ ) );
810 //.............................................................................
812 //.............................................................................
814 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */