1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "ObjectNameProvider.hxx"
33 #include "Strings.hrc"
35 #include "AxisHelper.hxx"
36 #include "ChartModelHelper.hxx"
37 #include "DiagramHelper.hxx"
38 #include "DataSeriesHelper.hxx"
39 #include "TitleHelper.hxx"
40 #include "AxisIndexDefines.hxx"
41 #include "ExplicitCategoriesProvider.hxx"
42 #include "CommonConverters.hxx"
43 #include "chartview/NumberFormatterWrapper.hxx"
44 #include "RegressionCurveHelper.hxx"
45 #include <rtl/math.hxx>
46 #include <tools/debug.hxx>
47 #include <tools/string.hxx>
49 #include <com/sun/star/chart2/XTitle.hpp>
50 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
52 //.............................................................................
55 //.............................................................................
56 using namespace ::com::sun::star
;
57 using namespace ::com::sun::star::chart2
;
58 using ::com::sun::star::uno::Reference
;
59 using ::com::sun::star::uno::Sequence
;
60 using ::com::sun::star::uno::Any
;
66 OUString
lcl_getDataSeriesName( const rtl::OUString
& rObjectCID
, const Reference
< frame::XModel
>& xChartModel
)
70 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
71 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
72 if( xDiagram
.is() && xSeries
.is() )
74 Reference
< XChartType
> xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram
, xSeries
) );
77 aRet
= ::chart::DataSeriesHelper::getDataSeriesLabel(
78 xSeries
, xChartType
->getRoleOfSequenceForSeriesLabel() ) ;
85 OUString
lcl_getFullSeriesName( const rtl::OUString
& rObjectCID
, const Reference
< frame::XModel
>& xChartModel
)
87 OUString aRet
= String(SchResId(STR_TIP_DATASERIES
));
88 OUString
aWildcard( C2U("%SERIESNAME") );
89 sal_Int32 nIndex
= aRet
.indexOf( aWildcard
);
91 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), lcl_getDataSeriesName( rObjectCID
, xChartModel
) );
95 void lcl_addText( OUString
& rOut
, const OUString
& rSeparator
, const OUString
& rNext
)
97 if( rOut
.getLength() && rNext
.getLength() )
99 if( rNext
.getLength() )
103 OUString
lcl_getDataPointValueText( const Reference
< XDataSeries
>& xSeries
, sal_Int32 nPointIndex
,
104 const Reference
< XCoordinateSystem
>& xCooSys
,
105 const Reference
< frame::XModel
>& xChartModel
)
110 Reference
<data::XDataSource
> xDataSource(
111 uno::Reference
<data::XDataSource
>( xSeries
, uno::UNO_QUERY
) );
112 if(!xDataSource
.is())
115 Sequence
< Reference
< data::XLabeledDataSequence
> > aDataSequences( xDataSource
->getDataSequences() );
117 rtl::OUString aX
, aY
, aY_Min
, aY_Max
, aY_First
, aY_Last
, a_Size
;
120 uno::Reference
< util::XNumberFormatsSupplier
> xNumberFormatsSupplier( xChartModel
, uno::UNO_QUERY
);
121 NumberFormatterWrapper
aNumberFormatterWrapper( xNumberFormatsSupplier
);
122 sal_Int32 nLabelColor
= 0;//dummy
123 bool bColorChanged
;//dummy
125 for(sal_Int32 nN
= aDataSequences
.getLength();nN
--;)
127 uno::Reference
<data::XDataSequence
> xDataSequence( aDataSequences
[nN
]->getValues());
128 if( !xDataSequence
.is() )
130 Sequence
< Any
> aData( xDataSequence
->getData() );
131 if( nPointIndex
>= aData
.getLength() )
133 uno::Reference
<beans::XPropertySet
> xProp(xDataSequence
, uno::UNO_QUERY
);
138 uno::Any aARole
= xProp
->getPropertyValue( C2U( "Role" ) );
142 if( aRole
.equals(C2U("values-x")) )
144 aData
[nPointIndex
]>>= fValue
;
145 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
146 aX
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
148 else if( aRole
.equals(C2U("values-y")) )
150 aData
[nPointIndex
]>>= fValue
;
151 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
152 aY
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
154 else if( aRole
.equals(C2U("values-first")) )
156 aData
[nPointIndex
]>>= fValue
;
157 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
158 aY_First
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
160 else if( aRole
.equals(C2U("values-min")) )
162 aData
[nPointIndex
]>>= fValue
;
163 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
164 aY_Min
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
166 else if( aRole
.equals(C2U("values-max")) )
168 aData
[nPointIndex
]>>= fValue
;
169 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
170 aY_Max
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
172 else if( aRole
.equals(C2U("values-last")) )
174 aData
[nPointIndex
]>>= fValue
;
175 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
176 aY_Last
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
178 else if( aRole
.equals(C2U("values-size")) )
180 aData
[nPointIndex
]>>= fValue
;
181 sal_Int32 nNumberFormatKey
= xDataSequence
->getNumberFormatKeyByIndex( nPointIndex
);
182 a_Size
= aNumberFormatterWrapper
.getFormattedString( nNumberFormatKey
, fValue
, nLabelColor
, bColorChanged
);
185 catch( uno::Exception
& e
)
187 ASSERT_EXCEPTION( e
);
192 if( aX
.getLength() == 0 )
194 rtl::OUString aCategory
= ::rtl::OUString( String(SchResId(STR_TIP_CATEGORY_VALUE
)));
196 replaceParamterInString( aCategory
197 , C2U("%CATEGORYVALUE")
198 , ExplicitCategoriesProvider::getCategoryByIndex( xCooSys
, xChartModel
, nPointIndex
)
208 OUString
aSeparator(C2U(" "));
210 lcl_addText( aRet
, aSeparator
, aY
);
211 lcl_addText( aRet
, aSeparator
, aY_First
);
212 lcl_addText( aRet
, aSeparator
, aY_Min
);
213 lcl_addText( aRet
, aSeparator
, aY_Max
);
214 lcl_addText( aRet
, aSeparator
, aY_Last
);
215 lcl_addText( aRet
, aSeparator
, a_Size
);
220 } //end anonymous namespace
222 rtl::OUString
ObjectNameProvider::getName( ObjectType eObjectType
, bool bPlural
)
225 switch( eObjectType
)
227 case OBJECTTYPE_PAGE
:
228 aRet
=String(SchResId(STR_OBJECT_PAGE
));
230 case OBJECTTYPE_TITLE
:
233 aRet
=String(SchResId(STR_OBJECT_TITLES
));
235 aRet
=String(SchResId(STR_OBJECT_TITLE
));
238 case OBJECTTYPE_LEGEND
:
239 aRet
=String(SchResId(STR_OBJECT_LEGEND
));
241 case OBJECTTYPE_LEGEND_ENTRY
:
242 aRet
=String(SchResId(STR_OBJECT_LEGEND_SYMBOL
));//@todo change string if we do differenciate symbol and legend entry in future
244 case OBJECTTYPE_DIAGRAM
:
245 aRet
=String(SchResId(STR_OBJECT_DIAGRAM
));
247 case OBJECTTYPE_DIAGRAM_WALL
:
248 aRet
=String(SchResId(STR_OBJECT_DIAGRAM_WALL
));
250 case OBJECTTYPE_DIAGRAM_FLOOR
:
251 aRet
=String(SchResId(STR_OBJECT_DIAGRAM_FLOOR
));
253 case OBJECTTYPE_AXIS
:
256 aRet
=String(SchResId(STR_OBJECT_AXES
));
258 aRet
=String(SchResId(STR_OBJECT_AXIS
));
261 case OBJECTTYPE_AXIS_UNITLABEL
:
262 aRet
=String(SchResId(STR_OBJECT_LABEL
));//@todo maybe a more concrete name
264 case OBJECTTYPE_GRID
:
265 case OBJECTTYPE_SUBGRID
: //maybe todo: different names for subgrids
268 aRet
=String(SchResId(STR_OBJECT_GRIDS
));
270 aRet
=String(SchResId(STR_OBJECT_GRID
));
273 case OBJECTTYPE_DATA_SERIES
:
276 aRet
=String(SchResId(STR_OBJECT_DATASERIES_PLURAL
));
278 aRet
=String(SchResId(STR_OBJECT_DATASERIES
));
281 case OBJECTTYPE_DATA_POINT
:
284 aRet
=String(SchResId(STR_OBJECT_DATAPOINTS
));
286 aRet
=String(SchResId(STR_OBJECT_DATAPOINT
));
289 case OBJECTTYPE_DATA_LABELS
:
290 aRet
=String(SchResId(STR_OBJECT_DATALABELS
));
292 case OBJECTTYPE_DATA_LABEL
:
293 aRet
=String(SchResId(STR_OBJECT_LABEL
));
295 case OBJECTTYPE_DATA_ERRORS
:
296 aRet
=String(SchResId(STR_OBJECT_ERROR_BARS
));//@todo? maybe distinguish plural singular
298 case OBJECTTYPE_DATA_ERRORS_X
:
299 aRet
=String(SchResId(STR_OBJECT_ERROR_BARS
));//@todo? maybe specialize in future
301 case OBJECTTYPE_DATA_ERRORS_Y
:
302 aRet
=String(SchResId(STR_OBJECT_ERROR_BARS
));//@todo? maybe specialize in future
304 case OBJECTTYPE_DATA_ERRORS_Z
:
305 aRet
=String(SchResId(STR_OBJECT_ERROR_BARS
));//@todo? maybe specialize in future
307 case OBJECTTYPE_DATA_AVERAGE_LINE
:
308 aRet
=String(SchResId(STR_OBJECT_AVERAGE_LINE
));
310 case OBJECTTYPE_DATA_CURVE
:
313 aRet
=String(SchResId(STR_OBJECT_CURVES
));
315 aRet
=String(SchResId(STR_OBJECT_CURVE
));
318 case OBJECTTYPE_DATA_STOCK_RANGE
:
319 //aRet=String(SchResId());
321 case OBJECTTYPE_DATA_STOCK_LOSS
:
322 aRet
=String(SchResId(STR_OBJECT_STOCK_LOSS
));
324 case OBJECTTYPE_DATA_STOCK_GAIN
:
325 aRet
=String(SchResId(STR_OBJECT_STOCK_GAIN
));
327 case OBJECTTYPE_DATA_CURVE_EQUATION
:
328 aRet
=String(SchResId(STR_OBJECT_CURVE_EQUATION
));
330 default: //OBJECTTYPE_UNKNOWN
336 rtl::OUString
ObjectNameProvider::getAxisName( const rtl::OUString
& rObjectCID
337 , const uno::Reference
< frame::XModel
>& xChartModel
)
343 Reference
< XAxis
> xAxis(
344 ObjectIdentifier::getObjectPropertySet( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
346 sal_Int32 nCooSysIndex
= 0;
347 sal_Int32 nDimensionIndex
= 0;
348 sal_Int32 nAxisIndex
= 0;
349 AxisHelper::getIndicesForAxis( xAxis
, ChartModelHelper::findDiagram( xChartModel
), nCooSysIndex
, nDimensionIndex
, nAxisIndex
);
351 switch(nDimensionIndex
)
354 if( nAxisIndex
== 0 )
355 aRet
=String(SchResId(STR_OBJECT_AXIS_X
));
357 aRet
=String(SchResId(STR_OBJECT_SECONDARY_X_AXIS
));
360 if( nAxisIndex
== 0 )
361 aRet
=String(SchResId(STR_OBJECT_AXIS_Y
));
363 aRet
=String(SchResId(STR_OBJECT_SECONDARY_Y_AXIS
));
366 aRet
=String(SchResId(STR_OBJECT_AXIS_Z
));
369 aRet
=String(SchResId(STR_OBJECT_AXIS
));
377 OUString
ObjectNameProvider::getTitleNameByType( TitleHelper::eTitleType eType
)
383 case TitleHelper::MAIN_TITLE
:
384 aRet
=String(SchResId(STR_OBJECT_TITLE_MAIN
));
386 case TitleHelper::SUB_TITLE
:
387 aRet
=String(SchResId(STR_OBJECT_TITLE_SUB
));
389 case TitleHelper::X_AXIS_TITLE
:
390 aRet
=String(SchResId(STR_OBJECT_TITLE_X_AXIS
));
392 case TitleHelper::Y_AXIS_TITLE
:
393 aRet
=String(SchResId(STR_OBJECT_TITLE_Y_AXIS
));
395 case TitleHelper::Z_AXIS_TITLE
:
396 aRet
=String(SchResId(STR_OBJECT_TITLE_Z_AXIS
));
398 case TitleHelper::SECONDARY_X_AXIS_TITLE
:
399 aRet
=String(SchResId(STR_OBJECT_TITLE_SECONDARY_X_AXIS
));
401 case TitleHelper::SECONDARY_Y_AXIS_TITLE
:
402 aRet
=String(SchResId(STR_OBJECT_TITLE_SECONDARY_Y_AXIS
));
405 DBG_ERROR("unknown title type");
409 if( !aRet
.getLength() )
410 aRet
=String(SchResId(STR_OBJECT_TITLE
));
416 OUString
ObjectNameProvider::getTitleName( const OUString
& rObjectCID
417 , const Reference
< frame::XModel
>& xChartModel
)
421 Reference
< XTitle
> xTitle(
422 ObjectIdentifier::getObjectPropertySet( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
425 TitleHelper::eTitleType eType
;
426 if( TitleHelper::getTitleType( eType
, xTitle
, xChartModel
) )
427 aRet
= ObjectNameProvider::getTitleNameByType( eType
);
429 if( !aRet
.getLength() )
430 aRet
=String(SchResId(STR_OBJECT_TITLE
));
436 rtl::OUString
ObjectNameProvider::getGridName( const rtl::OUString
& rObjectCID
437 , const uno::Reference
< frame::XModel
>& xChartModel
)
442 sal_Int32 nCooSysIndex
= -1;
443 sal_Int32 nDimensionIndex
= -1;
444 sal_Int32 nAxisIndex
= -1;
445 Reference
< XAxis
> xAxis( ObjectIdentifier::getAxisForCID( rObjectCID
, xChartModel
) );
446 AxisHelper::getIndicesForAxis( xAxis
, ChartModelHelper::findDiagram( xChartModel
)
447 , nCooSysIndex
, nDimensionIndex
, nAxisIndex
);
449 bool bMainGrid
= (ObjectIdentifier::getObjectType( rObjectCID
) == OBJECTTYPE_GRID
);
453 switch(nDimensionIndex
)
456 aRet
=String(SchResId(STR_OBJECT_GRID_MAJOR_X
));
459 aRet
=String(SchResId(STR_OBJECT_GRID_MAJOR_Y
));
462 aRet
=String(SchResId(STR_OBJECT_GRID_MAJOR_Z
));
465 aRet
=String(SchResId(STR_OBJECT_GRID
));
471 switch(nDimensionIndex
)
474 aRet
=String(SchResId(STR_OBJECT_GRID_MINOR_X
));
477 aRet
=String(SchResId(STR_OBJECT_GRID_MINOR_Y
));
480 aRet
=String(SchResId(STR_OBJECT_GRID_MINOR_Z
));
483 aRet
=String(SchResId(STR_OBJECT_GRID
));
490 rtl::OUString
ObjectNameProvider::getHelpText( const rtl::OUString
& rObjectCID
, const Reference
< chart2::XChartDocument
>& xChartDocument
, bool bVerbose
)
492 return getHelpText( rObjectCID
, Reference
< frame::XModel
>( xChartDocument
, uno::UNO_QUERY
), bVerbose
);
495 rtl::OUString
ObjectNameProvider::getHelpText( const rtl::OUString
& rObjectCID
, const Reference
< frame::XModel
>& xChartModel
, bool bVerbose
)
498 ObjectType
eObjectType( ObjectIdentifier::getObjectType(rObjectCID
) );
499 if( OBJECTTYPE_AXIS
== eObjectType
)
501 aRet
=ObjectNameProvider::getAxisName( rObjectCID
, xChartModel
);
503 else if( OBJECTTYPE_GRID
== eObjectType
504 || OBJECTTYPE_SUBGRID
== eObjectType
)
506 aRet
=ObjectNameProvider::getGridName( rObjectCID
, xChartModel
);
508 else if( OBJECTTYPE_TITLE
== eObjectType
)
510 aRet
=ObjectNameProvider::getTitleName( rObjectCID
, xChartModel
);
512 else if( OBJECTTYPE_DATA_SERIES
== eObjectType
)
514 aRet
= lcl_getFullSeriesName( rObjectCID
, xChartModel
);
516 else if( OBJECTTYPE_DATA_POINT
== eObjectType
)
520 OUString
aNewLine(C2U("\n"));
522 aRet
=String(SchResId(STR_TIP_DATAPOINT_INDEX
));
524 aRet
+=String(SchResId(STR_TIP_DATASERIES
));
526 aRet
+=String(SchResId(STR_TIP_DATAPOINT_VALUES
));
529 aRet
=String(SchResId(STR_TIP_DATAPOINT
));
531 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
532 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
533 if( xDiagram
.is() && xSeries
.is() )
535 sal_Int32
nPointIndex( ObjectIdentifier::getParticleID(rObjectCID
).toInt32() );
537 //replace data point index
538 sal_Int32 nIndex
= -1;
539 OUString
aWildcard( C2U("%POINTNUMBER") );
540 nIndex
= aRet
.indexOf( aWildcard
);
543 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), OUString::valueOf(nPointIndex
+1) );
546 //replace data series index
547 aWildcard
= C2U("%SERIESNUMBER");
548 nIndex
= aRet
.indexOf( aWildcard
);
551 ::std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVector(
552 DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
553 sal_Int32 nSeriesIndex
= -1;
554 for( nSeriesIndex
=aSeriesVector
.size();nSeriesIndex
--;)
556 if( aSeriesVector
[nSeriesIndex
] == xSeries
)
562 OUString
aReplacement( OUString::valueOf(nSeriesIndex
+1) );
563 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), aReplacement
);
566 //replace point values
567 aWildcard
= C2U("%POINTVALUES");
568 nIndex
= aRet
.indexOf( aWildcard
);
570 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), lcl_getDataPointValueText(
571 xSeries
,nPointIndex
, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries
, xDiagram
), xChartModel
) );
573 //replace series name
574 aWildcard
= C2U("%SERIESNAME");
575 nIndex
= aRet
.indexOf( aWildcard
);
577 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), lcl_getDataSeriesName( rObjectCID
, xChartModel
) );
581 else if( OBJECTTYPE_DIAGRAM == eObjectType )
583 //todo different names for different diagram types ???
584 //or different names for series of diferent charttypes
587 else if( OBJECTTYPE_DATA_CURVE
== eObjectType
)
591 aRet
= String( SchResId( STR_OBJECT_CURVE_WITH_PARAMETERS
));
592 Reference
< chart2::XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
));
593 Reference
< chart2::XRegressionCurveContainer
> xCurveCnt( xSeries
, uno::UNO_QUERY
);
596 Reference
< chart2::XRegressionCurve
> xCurve( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt
));
601 Reference
< chart2::XRegressionCurveCalculator
> xCalculator( xCurve
->getCalculator(), uno::UNO_QUERY_THROW
);
602 RegressionCurveHelper::initializeCurveCalculator( xCalculator
, xSeries
, xChartModel
);
605 sal_Int32 nIndex
= -1;
606 OUString
aWildcard( C2U("%FORMULA") );
607 nIndex
= aRet
.indexOf( aWildcard
);
609 aRet
= aRet
.replaceAt( nIndex
, aWildcard
.getLength(), xCalculator
->getRepresentation());
612 aWildcard
= C2U("%RSQUARED");
613 nIndex
= aRet
.indexOf( aWildcard
);
616 sal_Unicode
aDecimalSep( '.' );
617 //@todo: enable this code when a localized decimal
618 //separator is also available for the formula
619 // SvtSysLocale aSysLocale;
620 // OUString aSep( aSysLocale.GetLocaleData().getNumDecimalSep());
621 // if( aSep.getLength() == 1 )
622 // aDecimalSep = aSep.toChar();
623 double fR( xCalculator
->getCorrelationCoefficient());
624 aRet
= aRet
.replaceAt(
625 nIndex
, aWildcard
.getLength(),
626 ::rtl::math::doubleToUString(
627 fR
*fR
, rtl_math_StringFormat_G
, 4, aDecimalSep
, true ));
630 catch( const uno::Exception
& ex
)
632 ASSERT_EXCEPTION( ex
);
640 aRet
= ObjectNameProvider::getName( eObjectType
, false );
643 else if( OBJECTTYPE_DATA_AVERAGE_LINE
== eObjectType
)
647 aRet
= String( SchResId( STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS
));
648 Reference
< chart2::XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
));
649 Reference
< chart2::XRegressionCurveContainer
> xCurveCnt( xSeries
, uno::UNO_QUERY
);
652 Reference
< chart2::XRegressionCurve
> xCurve( RegressionCurveHelper::getMeanValueLine( xCurveCnt
));
657 Reference
< chart2::XRegressionCurveCalculator
> xCalculator( xCurve
->getCalculator(), uno::UNO_QUERY_THROW
);
658 RegressionCurveHelper::initializeCurveCalculator( xCalculator
, xSeries
, xChartModel
);
660 sal_Unicode
aDecimalSep( '.' );
661 // replace average value
662 // SvtSysLocale aSysLocale;
663 // OUString aSep( aSysLocale.GetLocaleData().getNumDecimalSep());
664 // if( aSep.getLength() == 1 )
665 // aDecimalSep = aSep.toChar();
667 sal_Int32 nIndex
= -1;
668 OUString
aWildcard( C2U("%AVERAGE_VALUE") );
669 nIndex
= aRet
.indexOf( aWildcard
);
670 // as the curve is constant, the value at any x-value is ok
673 const double fMeanValue( xCalculator
->getCurveValue( 0.0 ));
674 aRet
= aRet
.replaceAt(
675 nIndex
, aWildcard
.getLength(),
676 ::rtl::math::doubleToUString(
677 fMeanValue
, rtl_math_StringFormat_G
, 4, aDecimalSep
, true ));
680 // replace standard deviation
681 aWildcard
= C2U("%STD_DEVIATION");
682 nIndex
= aRet
.indexOf( aWildcard
);
685 const double fStdDev( xCalculator
->getCorrelationCoefficient());
686 aRet
= aRet
.replaceAt(
687 nIndex
, aWildcard
.getLength(),
688 ::rtl::math::doubleToUString(
689 fStdDev
, rtl_math_StringFormat_G
, 4, aDecimalSep
, true ));
692 catch( const uno::Exception
& ex
)
694 ASSERT_EXCEPTION( ex
);
702 aRet
= ObjectNameProvider::getName( eObjectType
, false );
707 aRet
= ObjectNameProvider::getName( eObjectType
, false );
713 rtl::OUString
ObjectNameProvider::getSelectedObjectText( const rtl::OUString
& rObjectCID
, const ::com::sun::star::uno::Reference
< ::com::sun::star::chart2::XChartDocument
>& xChartDocument
)
716 ObjectType
eObjectType( ObjectIdentifier::getObjectType(rObjectCID
) );
717 Reference
< frame::XModel
> xChartModel( xChartDocument
, uno::UNO_QUERY
);
719 if( OBJECTTYPE_DATA_POINT
== eObjectType
)
721 aRet
= String( SchResId( STR_STATUS_DATAPOINT_MARKED
));
723 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
724 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID
, xChartModel
), uno::UNO_QUERY
);
725 if( xDiagram
.is() && xSeries
.is() )
727 sal_Int32
nPointIndex( ObjectIdentifier::getParticleID(rObjectCID
).toInt32() );
729 // replace data point index
730 replaceParamterInString( aRet
, C2U("%POINTNUMBER"), OUString::valueOf( nPointIndex
+ 1 ));
732 // replace data series index
734 ::std::vector
< Reference
< chart2::XDataSeries
> > aSeriesVector(
735 DiagramHelper::getDataSeriesFromDiagram( xDiagram
) );
736 sal_Int32 nSeriesIndex
= -1;
737 for( nSeriesIndex
=aSeriesVector
.size();nSeriesIndex
--;)
739 if( aSeriesVector
[nSeriesIndex
] == xSeries
)
742 replaceParamterInString( aRet
, C2U("%SERIESNUMBER"), OUString::valueOf( nSeriesIndex
+ 1 ) );
745 // replace point value
746 replaceParamterInString( aRet
, C2U("%POINTVALUES"), lcl_getDataPointValueText(
747 xSeries
, nPointIndex
, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries
, xDiagram
), xChartModel
) );
752 // use the verbose text including the formula for trend lines
753 const bool bVerbose( OBJECTTYPE_DATA_CURVE
== eObjectType
|| OBJECTTYPE_DATA_AVERAGE_LINE
== eObjectType
);
754 const OUString
aHelpText( getHelpText( rObjectCID
, xChartModel
, bVerbose
));
755 if( aHelpText
.getLength())
757 aRet
= String( SchResId( STR_STATUS_OBJECT_MARKED
));
758 replaceParamterInString( aRet
, C2U("%OBJECTNAME"), aHelpText
);
767 rtl::OUString
ObjectNameProvider::getNameForCID(
768 const rtl::OUString
& rObjectCID
,
769 const uno::Reference
< chart2::XChartDocument
>& xChartDocument
)
771 ObjectType
eType( ObjectIdentifier::getObjectType( rObjectCID
));
772 Reference
< frame::XModel
> xModel( xChartDocument
, uno::UNO_QUERY
);
776 case OBJECTTYPE_AXIS
:
777 return getAxisName( rObjectCID
, xModel
);
778 case OBJECTTYPE_TITLE
:
779 return getTitleName( rObjectCID
, xModel
);
780 case OBJECTTYPE_GRID
:
781 case OBJECTTYPE_SUBGRID
:
782 return getGridName( rObjectCID
, xModel
);
783 case OBJECTTYPE_DATA_SERIES
:
784 return lcl_getFullSeriesName( rObjectCID
, xModel
);
785 //case OBJECTTYPE_LEGEND_ENTRY:
786 case OBJECTTYPE_DATA_POINT
:
787 case OBJECTTYPE_DATA_LABELS
:
788 case OBJECTTYPE_DATA_LABEL
:
789 case OBJECTTYPE_DATA_ERRORS
:
790 case OBJECTTYPE_DATA_ERRORS_X
:
791 case OBJECTTYPE_DATA_ERRORS_Y
:
792 case OBJECTTYPE_DATA_ERRORS_Z
:
793 case OBJECTTYPE_DATA_CURVE
:
794 case OBJECTTYPE_DATA_AVERAGE_LINE
:
795 case OBJECTTYPE_DATA_CURVE_EQUATION
:
797 rtl::OUString aRet
= lcl_getFullSeriesName( rObjectCID
, xModel
);
799 if( eType
== OBJECTTYPE_DATA_POINT
|| eType
== OBJECTTYPE_DATA_LABEL
)
801 aRet
+= getName( OBJECTTYPE_DATA_POINT
);
802 sal_Int32 nPointIndex
= ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID
);
804 aRet
+= OUString::valueOf(nPointIndex
+1);
806 if( eType
== OBJECTTYPE_DATA_LABEL
)
809 aRet
+= getName( OBJECTTYPE_DATA_LABEL
);
813 aRet
+= getName( eType
);
820 return getName( eType
);
824 rtl::OUString
ObjectNameProvider::getName_ObjectForSeries(
825 ObjectType eObjectType
,
826 const rtl::OUString
& rSeriesCID
,
827 const uno::Reference
< chart2::XChartDocument
>& xChartDocument
)
829 uno::Reference
< frame::XModel
> xChartModel( xChartDocument
, uno::UNO_QUERY
);
830 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID( rSeriesCID
, xChartModel
), uno::UNO_QUERY
);
833 OUString aRet
= String(SchResId(STR_OBJECT_FOR_SERIES
));
834 replaceParamterInString( aRet
, C2U("%OBJECTNAME"), getName( eObjectType
, false /*bPlural*/ ) );
835 replaceParamterInString( aRet
, C2U("%SERIESNAME"), lcl_getDataSeriesName( rSeriesCID
, xChartModel
) );
839 return ObjectNameProvider::getName_ObjectForAllSeries( eObjectType
);
843 rtl::OUString
ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType
)
845 OUString aRet
= String(SchResId(STR_OBJECT_FOR_ALL_SERIES
));
846 replaceParamterInString( aRet
, C2U("%OBJECTNAME"), getName( eObjectType
, true /*bPlural*/ ) );
850 //.............................................................................
852 //.............................................................................