32#include <unonames.hxx>
34#include <com/sun/star/chart/MissingValueTreatment.hpp>
35#include <com/sun/star/chart2/DataPointLabel.hpp>
36#include <com/sun/star/chart2/Symbol.hpp>
37#include <com/sun/star/chart2/XRegressionCurveCalculator.hpp>
38#include <com/sun/star/chart2/RelativePosition.hpp>
40#include <osl/diagnose.h>
43#include <com/sun/star/beans/XPropertySet.hpp>
44#include <com/sun/star/beans/XPropertyState.hpp>
50using ::com::sun::star::uno::Reference;
73 return std::numeric_limits<double>::quiet_NaN();
78 sal_Int32 nNumberFormatKey = -1;
83 nNumberFormatKey =
m_xModel->getNumberFormatKeyByIndex(
index );
86 return nNumberFormatKey;
96struct lcl_LessXOfPoint
98 bool operator() (
const std::vector< double >& first,
99 const std::vector< double >& second )
101 if( !
first.empty() && !second.empty() )
103 return first[0]<second[0];
109void lcl_clearIfNoValuesButTextIsContained( VDataSequence& rData,
const uno::Reference<data::XDataSequence>& xDataSequence )
112 sal_Int32
nCount = rData.m_aValues.getLength();
113 for( sal_Int32 i = 0;
i <
nCount; ++
i )
115 if( !std::isnan( rData.m_aValues[i] ) )
121 sal_Int32 nTextCount = aStrings.getLength();
122 for( sal_Int32 j = 0; j < nTextCount; ++j )
124 if( !aStrings[j].isEmpty() )
133void lcl_maybeReplaceNanWithZero(
double& rfValue, sal_Int32 nMissingValueTreatment )
135 if( nMissingValueTreatment == css::chart::MissingValueTreatment::USE_ZERO
136 && (std::isnan(rfValue) || std::isinf(rfValue)) )
147 , m_xDataSeries(xDataSeries)
149 , m_pValueSequenceForDataLabelNumberFormatDetection(&m_aValues_Y)
150 , m_fXMeanValue(
std::numeric_limits<double>::quiet_NaN())
151 , m_fYMeanValue(
std::numeric_limits<double>::quiet_NaN())
152 , m_eStackingDirection(StackingDirection_NO_STACKING)
154 , m_bConnectBars(false)
155 , m_bGroupBarsPerAxis(true)
156 , m_nStartingAngle(90)
157 , m_nGlobalSeriesIndex(0)
158 , m_nCurrentAttributedPoint(-1)
159 , m_nMissingValueTreatment(css::
chart::MissingValueTreatment::LEAVE_GAP)
160 , m_bAllowPercentValueInDataLabel(false)
161 , mpOldSeries(nullptr)
164 m_xDataSeriesProps = m_xDataSeries;
166 const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aDataSequences =
167 m_xDataSeries->getDataSequences2();
169 for(sal_Int32 nN = aDataSequences.size();nN--;)
171 uno::Reference<data::XDataSequence> xDataSequence( aDataSequences[nN]->getValues());
172 uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY );
177 uno::Any aARole = xProp->getPropertyValue(
"Role");
181 if (aRole ==
"values-x")
183 m_aValues_X.init( xDataSequence );
184 lcl_clearIfNoValuesButTextIsContained( m_aValues_X, xDataSequence );
186 else if (aRole ==
"values-y")
187 m_aValues_Y.init( xDataSequence );
188 else if (aRole ==
"values-min")
189 m_aValues_Y_Min.init( xDataSequence );
190 else if (aRole ==
"values-max")
191 m_aValues_Y_Max.init( xDataSequence );
192 else if (aRole ==
"values-first")
193 m_aValues_Y_First.init( xDataSequence );
194 else if (aRole ==
"values-last")
195 m_aValues_Y_Last.init( xDataSequence );
196 else if (aRole ==
"values-size")
197 m_aValues_Bubble_Size.init( xDataSequence );
200 VDataSequence aSequence;
201 aSequence.init(xDataSequence);
202 m_PropertyMap.insert(std::make_pair(aRole, aSequence));
205 catch(
const uno::Exception& )
213 m_nPointCount = m_aValues_Y.getLength();
215 if( m_nPointCount < m_aValues_Bubble_Size.getLength() )
216 m_nPointCount = m_aValues_Bubble_Size.getLength();
217 if( m_nPointCount < m_aValues_Y_Min.getLength() )
218 m_nPointCount = m_aValues_Y_Min.getLength();
219 if( m_nPointCount < m_aValues_Y_Max.getLength() )
220 m_nPointCount = m_aValues_Y_Max.getLength();
221 if( m_nPointCount < m_aValues_Y_First.getLength() )
222 m_nPointCount = m_aValues_Y_First.getLength();
223 if( m_nPointCount < m_aValues_Y_Last.getLength() )
224 m_nPointCount = m_aValues_Y_Last.getLength();
227 if( !xDataSeries.is())
241 catch(
const uno::Exception& )
257 std::vector< std::vector< double > > aTmp;
258 sal_Int32 nPointIndex = 0;
259 for( nPointIndex=0; nPointIndex <
m_nPointCount; nPointIndex++ )
263 : std::numeric_limits<double>::quiet_NaN()),
265 : std::numeric_limits<double>::quiet_NaN())
271 std::stable_sort( aTmp.begin(), aTmp.end(), lcl_LessXOfPoint() );
279 for( nPointIndex=0; nPointIndex <
m_nPointCount; nPointIndex++ )
281 pDoublesX[nPointIndex]=aTmp[nPointIndex][0];
282 pDoublesY[nPointIndex]=aTmp[nPointIndex][1];
323 lcl_clearIfNoValuesButTextIsContained(
m_aValues_X, xValues );
414 if( nAttachedAxisIndex < 0 )
415 nAttachedAxisIndex = 0;
421 double fRet = std::numeric_limits<double>::quiet_NaN();
430 fRet = nOldVal + (fRet - nOldVal) *
mnPercent;
446 double fRet = std::numeric_limits<double>::quiet_NaN();
455 fRet = nOldVal + (fRet - nOldVal) *
mnPercent;
471 fMax = std::numeric_limits<double>::quiet_NaN();
472 fMin = std::numeric_limits<double>::quiet_NaN();
476 if(!aValuesX.hasElements())
480 while (
i < aValuesX.getLength() && std::isnan(aValuesX[
i]) )
482 if (
i < aValuesX.getLength() )
483 fMax = fMin = aValuesX[
i++];
485 for ( ;
i < aValuesX.getLength();
i++)
487 const double aValue = aValuesX[
i];
492 else if ( aValue < fMin)
520 nNewVal = nOldVal + (nNewVal - nOldVal) *
mnPercent;
529 bool bHasNumberFormat =
false;
530 bool bLinkToSource =
true;
534 sal_Int32 nNumberFormat = -1;
535 if( !bLinkToSource && (xPointProp->getPropertyValue(
aPropName) >>= nNumberFormat))
536 bHasNumberFormat =
true;
538 return bHasNumberFormat;
543 sal_Int32 nNumberFormat = -1;
545 if( xPointProp.is() )
546 xPointProp->getPropertyValue(
aPropName) >>= nNumberFormat;
547 return nNumberFormat;
551 if (rRole ==
u"values-y")
553 else if (rRole ==
u"values-size")
555 else if (rRole ==
u"values-min")
557 else if (rRole ==
u"values-max")
559 else if (rRole ==
u"values-first")
561 else if (rRole ==
u"values-last")
563 else if (rRole ==
u"values-x")
576 sal_Int32 nLabelPlacement=0;
580 if( xPointProps.is() )
581 xPointProps->getPropertyValue(
"LabelPlacement") >>= nLabelPlacement;
586 for( sal_Int32
n : aAvailablePlacements )
587 if(
n == nLabelPlacement )
588 return nLabelPlacement;
591 if( aAvailablePlacements.hasElements() )
593 nLabelPlacement = aAvailablePlacements[0];
594 if( xPointProps.is() )
595 xPointProps->setPropertyValue(
"LabelPlacement",
uno::Any(nLabelPlacement));
596 return nLabelPlacement;
599 OSL_FAIL(
"no label placement supported");
601 catch(
const uno::Exception& )
605 return nLabelPlacement;
610 awt::Point aPos(-1, -1);
613 RelativePosition aCustomLabelPosition;
615 if( xPointProps.is() && (xPointProps->getPropertyValue(
"CustomLabelPosition") >>= aCustomLabelPosition))
617 aPos.X =
static_cast<sal_Int32
>(aCustomLabelPosition.Primary *
m_aReferenceSize.Width) + aTextShapePos.X;
618 aPos.Y =
static_cast<sal_Int32
>(aCustomLabelPosition.Secondary *
m_aReferenceSize.Height) + aTextShapePos.Y;
621 catch (
const uno::Exception&)
630 bool bCustom =
false;
636 RelativePosition aCustomLabelPosition;
637 if( xPointProps.is() && (xPointProps->getPropertyValue(
"CustomLabelPosition") >>= aCustomLabelPosition) )
641 catch (
const uno::Exception&)
650 double fMin = std::numeric_limits<double>::infinity();
677 if( std::isinf(fMin) )
678 return std::numeric_limits<double>::quiet_NaN();
685 double fMax = -std::numeric_limits<double>::infinity();
712 if( std::isinf(fMax) )
713 return std::numeric_limits<double>::quiet_NaN();
752 xCalculator->recalculateRegression( aXValuesDummy,
getAllX() );
765 xCalculator->recalculateRegression( aXValuesDummy,
getAllY() );
776 if( xProp->getPropertyValue(
"Symbol") >>= aSymbolProps )
779 xProp->getPropertyValue(
"Color") >>= aSymbolProps.FillColor;
781 aSymbolProps.BorderColor = aSymbolProps.FillColor;
786 catch(
const uno::Exception &)
805 if( !pRet || pRet->Style == SymbolStyle_NONE )
833 if( pRet && pRet->Style == SymbolStyle_AUTO )
835 pRet->Style = SymbolStyle_STANDARD;
840 pRet->StandardSymbol =
nIndex;
851 if( xPointProp.is() )
853 return xErrorBarProp;
861 if( xPointProp.is() )
863 return xErrorBarProp;
874 return (xPointState->getPropertyState(
"Color") != beans::PropertyState_DEFAULT_VALUE );
876 catch(
const uno::Exception&)
898 bool bVaryColorsByPoint =
false;
901 return bVaryColorsByPoint;
918 std::optional< DataPointLabel > apLabel( std::in_place );
924 catch(
const uno::Exception &)
945 DataPointLabel* pRet =
nullptr;
966 pRet->ShowNumberInPercent =
false;
974 if( !pLabel || (!pLabel->ShowNumber && !pLabel->ShowNumberInPercent
975 && !pLabel->ShowCategoryName && !pLabel->ShowCustomLabel && !pLabel->ShowSeriesName ) )
984 pPropNames =
nullptr; pPropValues =
nullptr;
986 bool bDoDynamicFontResize =
false;
998 bDoDynamicFontResize =
true;
1013 bDoDynamicFontResize =
true;
1019 if( bDoDynamicFontResize &&
1020 pPropNames && pPropValues &&
1026 return (pPropNames && pPropValues);
1040 : m_nPolygonIndex(0)
1045 , m_pValueSequenceForDataLabelNumberFormatDetection(nullptr)
1048 , m_eStackingDirection(chart2::StackingDirection_NO_STACKING)
1050 , m_bConnectBars(false)
1051 , m_bGroupBarsPerAxis(false)
1052 , m_nStartingAngle(0)
1053 , m_nGlobalSeriesIndex(0)
1054 , m_nCurrentAttributedPoint(0)
1055 , m_nMissingValueTreatment(0)
1056 , m_bAllowPercentValueInDataLabel(false)
1057 , mpOldSeries(nullptr)
1091 return std::numeric_limits<double>::quiet_NaN();
1098 if(rPropName.endsWith(
"Color"))
1108 return sal_uInt32(aRet);
1110 return fOldValue + (fValue - fOldValue) *
mnPercent;
sal_uInt8 GetBlue() const
sal_uInt8 GetAlpha() const
sal_uInt8 GetGreen() const
static css::uno::Sequence< sal_Int32 > getSupportedLabelPlacements(const rtl::Reference< ::chart::ChartType > &xChartType, bool bSwapXAndY, const rtl::Reference< ::chart::DataSeries > &xSeries)
static void doDynamicFontResize(tAnySequence &rPropValues, const tNameSequence &rPropNames, const css::uno::Reference< css::beans::XPropertySet > &xAxisModelProps, const css::awt::Size &rNewReferenceSize)
static OUString createClassifiedIdentifierForParticle(std::u16string_view rParticle)
static OUString createDataCurveEquationCID(std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex)
static OUString getStringForType(ObjectType eObjectType)
static OUString createDataCurveCID(std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex, bool bAverageLine)
static OUString createClassifiedIdentifierForParticles(std::u16string_view rParentParticle, std::u16string_view rChildParticle, std::u16string_view rDragMethodServiceName=std::u16string_view(), std::u16string_view rDragParameterString=std::u16string_view())
static OUString createSeriesSubObjectStub(ObjectType eSubObjectType, std::u16string_view rSeriesParticle, std::u16string_view rDragMethodServiceName=std::u16string_view(), std::u16string_view rDragParameterString=std::u16string_view())
static OUString createClassifiedIdentifierWithParent(enum ObjectType, std::u16string_view rParticleID, std::u16string_view rParentPartical, std::u16string_view rDragMethodServiceName=std::u16string_view(), std::u16string_view rDragParameterString=std::u16string_view())
static void getTextLabelMultiPropertyLists(const css::uno::Reference< css::beans::XPropertySet > &xSourceProp, tNameSequence &rPropNames, tAnySequence &rPropValues, bool bName=true, sal_Int32 nLimitedSpace=-1, bool bLimitedHeight=false, bool bSupportsLabelBorder=true)
css::uno::Reference< css::chart2::data::XDataSequence > m_xModel
sal_Int32 getLength() const
void init(const css::uno::Reference< css::chart2::data::XDataSequence > &xModel)
double getValue(sal_Int32 index) const
css::uno::Sequence< double > m_aValues
sal_Int32 detectNumberFormatKey(sal_Int32 index) const
rtl::Reference< SvxShapeGroupAnyD > m_xGroupShape
bool hasExplicitNumberFormat(sal_Int32 nPointIndex, bool bForPercentage) const
css::awt::Point getLabelPosition(css::awt::Point aTextShapePos, sal_Int32 nPointIndex) const
sal_Int32 getExplicitNumberFormat(sal_Int32 nPointIndex, bool bForPercentage) const
css::chart2::StackingDirection getStackingDirection() const
OUString getDataCurveCID(sal_Int32 nCurveIndex, bool bAverageLine) const
void setOldTimeBased(VDataSeries *pOldSeries, double nPercent)
sal_Int32 getAttachedAxisIndex() const
void getMinMaxXValue(double &fMin, double &fMax) const
double getYMeanValue() const
rtl::Reference< SvxShapeGroupAnyD > m_xErrorYBarsGroupShape
OUString m_aSeriesParticle
void adaptPointCache(sal_Int32 nNewPointIndex) const
bool getGroupBarsPerAxis() const
std::vector< std::vector< css::drawing::Position3D > > m_aPolyPolygonShape3D
bool isVaryColorsByPoint() const
VDataSequence m_aValues_X
css::chart2::Symbol * getSymbolProperties(sal_Int32 index) const
const css::uno::Reference< css::beans::XPropertySet > & getPropertiesOfSeries() const
css::uno::Sequence< double > const & getAllX() const
css::uno::Reference< css::beans::XPropertySet > getPropertiesOfPoint(sal_Int32 index) const
double getYValue(sal_Int32 index) const
css::chart2::StackingDirection m_eStackingDirection
rtl::Reference< SvxShapeGroup > m_xLabelsGroupShape
double getValueByProperty(sal_Int32 index, const OUString &rPropName) const
std::optional< tNameSequence > m_oLabelPropNames_Series
rtl::Reference< SvxShapeGroupAnyD > m_xErrorXBarsGroupShape
std::optional< css::chart2::Symbol > m_oSymbolProperties_Series
sal_Int32 m_nStartingAngle
void setXValuesIfNone(const css::uno::Reference< css::chart2::data::XDataSequence > &xValues)
VDataSequence m_aValues_Bubble_Size
css::chart2::DataPointLabel * getDataPointLabelIfLabel(sal_Int32 index) const
sal_Int32 getStartingAngle() const
void setXValues(const css::uno::Reference< css::chart2::data::XDataSequence > &xValues)
double getY_First(sal_Int32 index) const
css::uno::Reference< css::beans::XPropertySet > m_xDataSeriesProps
css::uno::Reference< css::beans::XPropertySet > getXErrorBarProperties(sal_Int32 index) const
sal_Int32 m_nPolygonIndex
std::unique_ptr< tAnySequence > m_apLabelPropValues_AttributedPoint
std::optional< css::chart2::DataPointLabel > m_oLabel_AttributedPoint
const rtl::Reference<::chart::DataSeries > & getModel() const
css::uno::Sequence< sal_Int32 > m_aAttributedDataPointIndexList
double getY_Max(sal_Int32 index) const
rtl::Reference< SvxShapeGroupAnyD > m_xBackSubGroupShape
VDataSequence m_aValues_Y_Max
VDataSeries * createCopyForTimeBased() const
double getMinimumofAllDifferentYValues(sal_Int32 index) const
css::chart2::DataPointLabel * getDataPointLabel(sal_Int32 index) const
std::map< OUString, VDataSequence > m_PropertyMap
OUString getErrorBarsCID(bool bYError) const
VDataSequence m_aValues_Y_Min
std::optional< css::chart2::Symbol > m_oSymbolProperties_InvisibleSymbolForSelection
VDataSeries * mpOldSeries
bool isAttributedDataPoint(sal_Int32 index) const
VDataSequence m_aValues_Y_First
std::optional< css::chart2::DataPointLabel > m_oLabel_Series
void setConnectBars(bool bConnectBars)
OUString m_aPointCID_Stub
VDataSequence m_aValues_Y_Last
sal_Int32 m_nGlobalSeriesIndex
sal_Int32 detectNumberFormatKey(sal_Int32 nPointIndex) const
bool hasPropertyMapping(const OUString &rPropName) const
sal_Int32 getLabelPlacement(sal_Int32 nPointIndex, const rtl::Reference<::chart::ChartType > &xChartType, bool bSwapXAndY) const
double getMaximumofAllDifferentYValues(sal_Int32 index) const
VDataSequence m_aValues_Y
std::optional< css::chart2::Symbol > m_oSymbolProperties_AttributedPoint
VDataSequence * m_pValueSequenceForDataLabelNumberFormatDetection
double getBubble_Size(sal_Int32 index) const
bool getConnectBars() const
void setGroupBarsPerAxis(bool bGroupBarsPerAxis)
double getXValue(sal_Int32 index) const
void setAttachedAxisIndex(sal_Int32 nAttachedAxisIndex)
void setGlobalSeriesIndex(sal_Int32 nGlobalSeriesIndex)
bool hasPointOwnColor(sal_Int32 index) const
double getXMeanValue() const
double getY_Last(sal_Int32 index) const
void setMissingValueTreatment(sal_Int32 nMissingValueTreatment)
double getY_Min(sal_Int32 index) const
sal_Int32 m_nMissingValueTreatment
OUString getDataCurveEquationCID(sal_Int32 nCurveIndex) const
css::awt::Size m_aReferenceSize
css::uno::Sequence< double > const & getAllY() const
OUString m_aLabelCID_Stub
std::optional< tAnySequence > m_oLabelPropValues_Series
css::uno::Reference< css::beans::XPropertySet > getYErrorBarProperties(sal_Int32 index) const
bool getTextLabelMultiPropertyLists(sal_Int32 index, tNameSequence *&pPropNames, tAnySequence *&pPropValues) const
void setStartingAngle(sal_Int32 nStartingAngle)
bool isLabelCustomPos(sal_Int32 nPointIndex) const
rtl::Reference<::chart::DataSeries > m_xDataSeries
void setParticle(const OUString &rSeriesParticle)
rtl::Reference< SvxShapeGroupAnyD > m_xFrontSubGroupShape
VDataSequence m_aValues_Z
OUString getLabelsCID() const
std::unique_ptr< tNameSequence > m_apLabelPropNames_AttributedPoint
void setRoleOfSequenceForDataLabelNumberFormatDetection(std::u16string_view rRole)
bool m_bAllowPercentValueInDataLabel
void setPageReferenceSize(const css::awt::Size &rPageRefSize)
sal_Int32 getMissingValueTreatment() const
sal_Int32 m_nCurrentAttributedPoint
#define TOOLS_WARN_EXCEPTION(area, stream)
std::unique_ptr< sal_Int32[]> pData
@ PROP_DATASERIES_ATTRIBUTED_DATA_POINTS
@ PROP_DATASERIES_STACKING_DIRECTION
@ PROP_DATASERIES_VARY_COLORS_BY_POINT
@ PROP_DATASERIES_ATTACHED_AXIS_INDEX
OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveCalculator > createRegressionCurveCalculatorByServiceName(std::u16string_view aServiceName)
returns a calculator object for regression curves (used by the view)
@ OBJECTTYPE_DATA_ERRORS_X
@ OBJECTTYPE_DATA_ERRORS_Y
css::uno::Sequence< OUString > tNameSequence
css::uno::Sequence< css::uno::Any > tAnySequence
OOO_DLLPUBLIC_CHARTTOOLS css::uno::Sequence< double > DataSequenceToDoubleSequence(const css::uno::Reference< css::chart2::data::XDataSequence > &xDataSequence)
chart2::XDataSequence -> uno::Sequence< double >
static std::optional< Symbol > getSymbolPropertiesFromPropertySet(const uno::Reference< beans::XPropertySet > &xProp)
OOO_DLLPUBLIC_CHARTTOOLS css::uno::Sequence< OUString > DataSequenceToStringSequence(const css::uno::Reference< css::chart2::data::XDataSequence > &xDataSequence)
static std::optional< DataPointLabel > getDataPointLabelFromPropertySet(const uno::Reference< beans::XPropertySet > &xProp)
constexpr OUStringLiteral first
Reference< XModel > xModel
constexpr OUStringLiteral CHART_UNONAME_ERRORBAR_Y
constexpr OUStringLiteral CHART_UNONAME_LINK_TO_SRC_NUMFMT
constexpr OUStringLiteral CHART_UNONAME_NUMFMT
constexpr OUStringLiteral CHART_UNONAME_ERRORBAR_X
constexpr OUStringLiteral CHART_UNONAME_LABEL