43#include <rtl/math.hxx>
44#include <rtl/ustring.hxx>
49#include <com/sun/star/chart2/XTitle.hpp>
50#include <com/sun/star/chart2/MovingAverageType.hpp>
58using ::com::sun::star::uno::Reference;
59using ::com::sun::star::uno::Sequence;
60using ::com::sun::star::uno::Any;
71 if( xDiagram.is() && xSeries.is() )
76 aRet = xSeries->getLabelForRole(
77 xChartType->getRoleOfSequenceForSeriesLabel() ) ;
86 OUString aRet(
SchResId(STR_TIP_DATASERIES));
88 sal_Int32
nIndex = aRet.indexOf( aWildcard );
90 aRet = aRet.replaceAt( nIndex,
aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) );
94void lcl_addText( OUString& rOut, std::u16string_view rSeparator, std::u16string_view rNext )
96 if( !(rOut.isEmpty() || rNext.empty()) )
104 const Reference< frame::XModel >& xChartModel )
112 const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aDataSequences = xSeries->getDataSequences2();
114 OUString aX, aY, aY_Min, aY_Max, aY_First, aY_Last, a_Size;
117 uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY );
118 NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier );
122 for(sal_Int32 nN = aDataSequences.size();nN--;)
124 uno::Reference<data::XDataSequence> xDataSequence( aDataSequences[nN]->getValues());
125 if( !xDataSequence.is() )
130 Sequence< Any >
aData( xDataSequence->getData() );
132 if( nPointIndex >=
aData.getLength() )
134 uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY );
137 uno::Any aARole = xProp->getPropertyValue(
"Role" );
141 if( aRole ==
"values-x" )
143 aData[nPointIndex]>>= fValue;
144 sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
145 aX = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
147 else if( aRole ==
"values-y")
149 aData[nPointIndex]>>= fValue;
150 sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
151 aY = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
153 else if( aRole ==
"values-first" )
155 aData[nPointIndex]>>= fValue;
156 sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
157 aY_First = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
159 else if( aRole ==
"values-min" )
161 aData[nPointIndex]>>= fValue;
162 sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
163 aY_Min = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
165 else if( aRole ==
"values-max" )
167 aData[nPointIndex]>>= fValue;
168 sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
169 aY_Max = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
171 else if( aRole ==
"values-last" )
173 aData[nPointIndex]>>= fValue;
174 sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
175 aY_Last = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
177 else if( aRole ==
"values-size" )
179 aData[nPointIndex]>>= fValue;
180 sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex );
181 a_Size = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged );
185 catch (
const lang::DisposedException&)
189 catch(
const uno::Exception& )
197 ChartModel& rModel =
dynamic_cast<ChartModel&
>(*xChartModel);
205 OUString aSeparator(
" " );
207 lcl_addText( aRet, aSeparator, aY );
208 lcl_addText( aRet, aSeparator, aY_First );
209 lcl_addText( aRet, aSeparator, aY_Min );
210 lcl_addText( aRet, aSeparator, aY_Max );
211 lcl_addText( aRet, aSeparator, aY_Last );
212 lcl_addText( aRet, aSeparator, a_Size );
222 switch( eObjectType )
239 aRet=
SchResId(STR_OBJECT_LEGEND_SYMBOL);
245 aRet=
SchResId(STR_OBJECT_DIAGRAM_WALL);
248 aRet=
SchResId(STR_OBJECT_DIAGRAM_FLOOR);
273 aRet=
SchResId(STR_OBJECT_DATASERIES_PLURAL);
275 aRet=
SchResId(STR_OBJECT_DATASERIES);
281 aRet=
SchResId(STR_OBJECT_DATAPOINTS);
283 aRet=
SchResId(STR_OBJECT_DATAPOINT);
287 aRet=
SchResId(STR_OBJECT_DATALABELS);
293 aRet=
SchResId(STR_OBJECT_ERROR_BARS_X);
296 aRet=
SchResId(STR_OBJECT_ERROR_BARS_Y);
299 aRet=
SchResId(STR_OBJECT_ERROR_BARS_Z);
302 aRet=
SchResId(STR_OBJECT_AVERAGE_LINE);
315 aRet=
SchResId(STR_OBJECT_STOCK_LOSS);
318 aRet=
SchResId(STR_OBJECT_STOCK_GAIN);
321 aRet=
SchResId(STR_OBJECT_CURVE_EQUATION);
340 sal_Int32 nCooSysIndex = 0;
341 sal_Int32 nDimensionIndex = 0;
342 sal_Int32 nAxisIndex = 0;
345 switch(nDimensionIndex)
348 if( nAxisIndex == 0 )
351 aRet=
SchResId(STR_OBJECT_SECONDARY_X_AXIS);
354 if( nAxisIndex == 0 )
357 aRet=
SchResId(STR_OBJECT_SECONDARY_Y_AXIS);
377 aRet=
SchResId(STR_OBJECT_TITLE_MAIN);
380 aRet=
SchResId(STR_OBJECT_TITLE_SUB);
383 aRet=
SchResId(STR_OBJECT_TITLE_X_AXIS);
386 aRet=
SchResId(STR_OBJECT_TITLE_Y_AXIS);
389 aRet=
SchResId(STR_OBJECT_TITLE_Z_AXIS);
392 aRet=
SchResId(STR_OBJECT_TITLE_SECONDARY_X_AXIS);
395 aRet=
SchResId(STR_OBJECT_TITLE_SECONDARY_Y_AXIS);
398 OSL_FAIL(
"unknown title type");
432 sal_Int32 nCooSysIndex = -1;
433 sal_Int32 nDimensionIndex = -1;
434 sal_Int32 nAxisIndex = -1;
437 , nCooSysIndex , nDimensionIndex, nAxisIndex );
443 switch(nDimensionIndex)
446 aRet=
SchResId(STR_OBJECT_GRID_MAJOR_X);
449 aRet=
SchResId(STR_OBJECT_GRID_MAJOR_Y);
452 aRet=
SchResId(STR_OBJECT_GRID_MAJOR_Z);
461 switch(nDimensionIndex)
464 aRet=
SchResId(STR_OBJECT_GRID_MINOR_X);
467 aRet=
SchResId(STR_OBJECT_GRID_MINOR_Y);
470 aRet=
SchResId(STR_OBJECT_GRID_MINOR_Z);
499 aRet = lcl_getFullSeriesName( rObjectCID, xChartModel );
505 aRet=
SchResId(STR_TIP_DATAPOINT_INDEX) +
"\n"
506 +
SchResId(STR_TIP_DATASERIES) +
"\n"
507 +
SchResId(STR_TIP_DATAPOINT_VALUES);
514 if( xDiagram.is() && xSeries.is() )
523 aRet = aRet.replaceAt(
nIndex,
aWildcard.getLength(), OUString::number(nPointIndex+1) );
531 std::vector< rtl::Reference< DataSeries > > aSeriesVector =
532 xDiagram->getDataSeries();
533 sal_Int32 nSeriesIndex = -1;
534 for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;)
536 if( aSeriesVector[nSeriesIndex] == xSeries )
542 OUString aReplacement( OUString::number(nSeriesIndex+1) );
550 aRet = aRet.replaceAt(
nIndex,
aWildcard.getLength(), lcl_getDataPointValueText(
557 aRet = aRet.replaceAt(
nIndex,
aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) );
564 aRet =
SchResId( STR_OBJECT_CURVE_WITH_PARAMETERS );
576 sal_Int32 aDegree = 2;
577 sal_Int32 aPeriod = 2;
578 sal_Int32 aMovingType = css::chart2::MovingAverageType::Prior;
579 bool bForceIntercept =
false;
580 double aInterceptValue = 0.0;
581 OUString aXName (
"x"), aYName (
"f(x)");
586 xCurve->getPropertyValue(
"PolynomialDegree") >>= aDegree;
587 xCurve->getPropertyValue(
"MovingAveragePeriod") >>= aPeriod;
588 xCurve->getPropertyValue(
"MovingAverageType") >>= aMovingType;
589 xCurve->getPropertyValue(
"ForceIntercept") >>= bForceIntercept;
591 xCurve->getPropertyValue(
"InterceptValue") >>= aInterceptValue;
595 if ( !(xEqProp->getPropertyValue(
"XName") >>= aXName) )
597 if ( !(xEqProp->getPropertyValue(
"YName") >>= aYName) )
600 xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, aPeriod, aMovingType);
601 xCalculator->setXYNames ( aXName, aYName );
607 aRet = xCalculator->getRepresentation();
616 OUString aFormula ( xCalculator->getRepresentation() );
617 if ( cDecSeparator !=
'.' )
619 aFormula = aFormula.replace(
'.', cDecSeparator );
629 double fR( xCalculator->getCorrelationCoefficient());
630 aRet = aRet.replaceAt(
632 ::rtl::math::doubleToUString(
633 fR*fR, rtl_math_StringFormat_G, 4, cDecSeparator,
true ));
637 catch(
const uno::Exception & )
664 aRet =
SchResId(STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS);
685 const double fMeanValue( xCalculator->getCurveValue( 0.0 ));
686 aRet = aRet.replaceAt(
688 ::rtl::math::doubleToUString(
689 fMeanValue, rtl_math_StringFormat_G, 4, cDecSeparator,
true ));
697 const double fStdDev( xCalculator->getCorrelationCoefficient());
698 aRet = aRet.replaceAt(
700 ::rtl::math::doubleToUString(
701 fStdDev, rtl_math_StringFormat_G, 4, cDecSeparator,
true ));
704 catch(
const uno::Exception & )
731 aRet =
SchResId( STR_STATUS_DATAPOINT_MARKED );
735 if( xDiagram.is() && xSeries.is() )
744 std::vector< rtl::Reference< DataSeries > > aSeriesVector(
745 xDiagram->getDataSeries() );
746 sal_Int32 nSeriesIndex = -1;
747 for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;)
749 if( aSeriesVector[nSeriesIndex] == xSeries )
764 const OUString aHelpText(
getHelpText( rObjectCID, xChartDocument, bVerbose ));
765 if( !aHelpText.isEmpty())
767 aRet =
SchResId( STR_STATUS_OBJECT_MARKED );
776 std::u16string_view rObjectCID,
791 return lcl_getFullSeriesName( rObjectCID, xChartDocument );
802 OUString aRet = lcl_getFullSeriesName( rObjectCID, xChartDocument ) +
" ";
807 aRet +=
" " + OUString::number(nPointIndex+1);
844 std::u16string_view rSeriesCID,
850 OUString aRet =
SchResId(STR_OBJECT_FOR_SERIES);
861 OUString aRet =
SchResId(STR_OBJECT_FOR_ALL_SERIES);
const LocaleDataWrapper & GetLocaleDataWrapper() const
static const AllSettings & GetSettings()
const OUString & getNumDecimalSep() const
static bool getIndicesForAxis(const rtl::Reference< ::chart::Axis > &xAxis, const rtl::Reference< ::chart::BaseCoordinateSystem > &xCooSys, sal_Int32 &rOutDimensionIndex, sal_Int32 &rOutAxisIndex)
static OUString getCategoryByIndex(const rtl::Reference< ::chart::BaseCoordinateSystem > &xCooSysModel, ChartModel &rModel, sal_Int32 nIndex)
static rtl::Reference< ::chart::DataSeries > getDataSeriesForCID(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartModel)
static std::u16string_view getParticleID(std::u16string_view rCID)
static css::uno::Reference< css::beans::XPropertySet > getObjectPropertySet(std::u16string_view rObjectCID, const rtl::Reference< ::chart::ChartModel > &xChartDocument)
static rtl::Reference< ::chart::Axis > getAxisForCID(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartModel)
static sal_Int32 getIndexFromParticleOrCID(std::u16string_view rParticleOrCID)
ObjectType getObjectType() const
static OUString getName_ObjectForSeries(ObjectType eObjectType, std::u16string_view rSeriesCID, const rtl::Reference<::chart::ChartModel > &xChartDocument)
static OUString getName(ObjectType eObjectType, bool bPlural=false)
static OUString getAxisName(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartModel)
static OUString getSelectedObjectText(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartDocument)
This is used for showing the currently selected object in the status bar (command "Context")
static OUString getGridName(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartModel)
static OUString getTitleName(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartModel)
static OUString getTitleNameByType(TitleHelper::eTitleType eType)
static OUString getName_ObjectForAllSeries(ObjectType eObjectType)
static OUString getHelpText(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartModel, bool bVerbose=false)
Provides help texts for the various chart elements.
static OUString getNameForCID(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartDocument)
static bool getTitleType(eTitleType &rType, const rtl::Reference< ::chart::Title > &xTitle, const rtl::Reference< ::chart::ChartModel > &xModel)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr OUStringLiteral aData
OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference< ::chart::BaseCoordinateSystem > getCoordinateSystemOfSeries(const rtl::Reference< ::chart::DataSeries > &xSeries, const rtl::Reference< ::chart::Diagram > &xDiagram)
void initializeCurveCalculator(const css::uno::Reference< css::chart2::XRegressionCurveCalculator > &xOutCurveCalculator, const css::uno::Reference< css::chart2::data::XDataSource > &xSource, bool bUseXValuesIfAvailable)
recalculates the regression parameters according to the data given in the data source.
OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel > getRegressionCurveAtIndex(const rtl::Reference<::chart::DataSeries > &xCurveContainer, sal_Int32 aIndex)
Returns the regression curve found at the index provided.
OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel > getMeanValueLine(const css::uno::Reference< css::chart2::XRegressionCurveContainer > &xRegCnt)
OOO_DLLPUBLIC_CHARTTOOLS SvxChartRegress getRegressionType(const css::uno::Reference< css::chart2::XRegressionCurve > &xCurve)
OOO_DLLPUBLIC_CHARTTOOLS OUString getRegressionCurveName(const css::uno::Reference< css::chart2::XRegressionCurve > &xCurve)
@ OBJECTTYPE_LEGEND_ENTRY
@ OBJECTTYPE_DATA_ERRORS_X
@ OBJECTTYPE_DATA_STOCK_LOSS
@ OBJECTTYPE_DIAGRAM_FLOOR
@ OBJECTTYPE_DATA_STOCK_RANGE
@ OBJECTTYPE_DATA_ERRORS_Y
@ OBJECTTYPE_AXIS_UNITLABEL
@ OBJECTTYPE_DATA_CURVE_EQUATION
@ OBJECTTYPE_DATA_STOCK_GAIN
@ OBJECTTYPE_DATA_AVERAGE_LINE
@ OBJECTTYPE_DATA_ERRORS_Z
@ OBJECTTYPE_DIAGRAM_WALL
OOO_DLLPUBLIC_CHARTTOOLS bool replaceParamterInString(OUString &rInOutResourceString, std::u16string_view rParamToReplace, std::u16string_view rReplaceWith)
OUString OOO_DLLPUBLIC_CHARTTOOLS SchResId(TranslateId aId)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)