27#include <com/sun/star/chart2/XRegressionCurve.hpp>
28#include <osl/diagnose.h>
39template <
class T,
class D>
40bool lclConvertToPropertySet(
const SfxItemSet& rItemSet, sal_uInt16 nWhichId,
const uno::Reference<beans::XPropertySet>& xProperties,
const OUString& aPropertyID)
42 OSL_ASSERT(xProperties.is());
43 if( xProperties.is() )
45 T aValue =
static_cast<T
>(
static_cast<const D&
>(rItemSet.
Get( nWhichId )).
GetValue());
47 bool aSuccess = xProperties->getPropertyValue( aPropertyID ) >>= aOldValue;
48 if (!aSuccess || aOldValue != aValue)
50 xProperties->setPropertyValue( aPropertyID ,
uno::Any( aValue ));
57template <
class T,
class D>
58void lclConvertToItemSet(
SfxItemSet& rItemSet, sal_uInt16 nWhichId,
const uno::Reference<beans::XPropertySet>& xProperties,
const OUString& aPropertyID)
60 OSL_ASSERT(xProperties.is());
61 if( xProperties.is() )
63 T aValue =
static_cast<T
>(
static_cast<const D&
>(rItemSet.
Get( nWhichId )).
GetValue());
64 if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
66 rItemSet.
Put(
D( nWhichId, aValue ));
73 OSL_ASSERT(xProperties.is());
74 if( xProperties.is() )
76 double aValue = rItemSet.
Get( nWhichId ).GetValue();
77 if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
97 rPropertySet, rItemPool, rDrawModel,
98 xNamedPropertyContainerFactory,
100 m_xCurveContainer(
std::move( xContainer ))
136 sal_uInt16 nWhichId,
const SfxItemSet & rItemSet )
139 bool bChanged =
false;
141 OSL_ASSERT(xCurve.is());
152 if( eRegress != eNewRegress )
172 bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties,
"PolynomialDegree");
179 bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties,
"MovingAveragePeriod");
186 bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties,
"ExtrapolateForward");
193 bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties,
"ExtrapolateBackward");
200 bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xProperties,
"ForceIntercept");
207 bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties,
"InterceptValue");
214 bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xProperties,
"CurveName");
221 bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties,
"MovingAverageType");
228 bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp,
"ShowEquation");
235 bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp,
"XName");
242 bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp,
"YName");
249 bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp,
"ShowCorrelationCoefficient");
260 OSL_ASSERT(xCurve.is());
277 lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties,
"PolynomialDegree");
283 lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties,
"MovingAveragePeriod");
301 lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xProperties,
"ForceIntercept");
313 lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xProperties,
"CurveName");
319 lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties,
"MovingAverageType");
325 lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(),
"ShowEquation");
331 lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(),
"XName");
337 lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(),
"YName");
343 lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(),
"ShowCorrelationCoefficient");
constexpr TypedWhichId< SvxChartRegressItem > SCHATTR_REGRESSION_TYPE(SCHATTR_REGRESSION_START)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD(SCHATTR_REGRESSION_START+5)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_REGRESSION_SHOW_EQUATION(SCHATTR_REGRESSION_START+1)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_REGRESSION_SET_INTERCEPT(SCHATTR_REGRESSION_START+7)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_REGRESSION_MOVING_TYPE(SCHATTR_REGRESSION_START+12)
constexpr TypedWhichId< SfxStringItem > SCHATTR_REGRESSION_CURVE_NAME(SCHATTR_REGRESSION_START+9)
constexpr TypedWhichId< SfxStringItem > SCHATTR_REGRESSION_YNAME(SCHATTR_REGRESSION_START+11)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_REGRESSION_DEGREE(SCHATTR_REGRESSION_START+3)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_REGRESSION_SHOW_COEFF(SCHATTR_REGRESSION_START+2)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD(SCHATTR_REGRESSION_START+6)
constexpr TypedWhichId< SfxStringItem > SCHATTR_REGRESSION_XNAME(SCHATTR_REGRESSION_START+10)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_REGRESSION_INTERCEPT_VALUE(SCHATTR_REGRESSION_START+8)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_REGRESSION_PERIOD(SCHATTR_REGRESSION_START+4)
const WhichRangesContainer nRegressionCurveWhichPairs(svl::Items< SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END, XATTR_LINE_FIRST, XATTR_LINE_LAST >)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
This class serves for conversion between properties of an XPropertySet and SfxItems in SfxItemSets.
void resetPropertySet(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
sets a new property set, that you get with GetPropertySet().
virtual void FillItemSet(SfxItemSet &rOutItemSet) const
applies all properties that can be mapped to items into the given item set.
std::pair< tPropertyNameType, tMemberIdType > tPropertyNameWithMemberId
const css::uno::Reference< css::beans::XPropertySet > & GetPropertySet() const
Returns the XPropertySet that was given in the CTOR and is used to apply items in ApplyItemSet().
virtual bool ApplyItemSet(const SfxItemSet &rItemSet)
applies all properties that are results of a conversion from all items in rItemSet to the internal XP...
std::shared_ptr< ItemConverter > m_spGraphicConverter
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
virtual void FillItemSet(SfxItemSet &rOutItemSet) const override
applies all properties that can be mapped to items into the given item set.
rtl::Reference< ::chart::DataSeries > m_xCurveContainer
RegressionCurveItemConverter(const css::uno::Reference< css::beans::XPropertySet > &rPropertySet, rtl::Reference< ::chart::DataSeries > xRegCurveCnt, SfxItemPool &rItemPool, SdrModel &rDrawModel, const css::uno::Reference< css::lang::XMultiServiceFactory > &xNamedPropertyContainerFactory)
virtual ~RegressionCurveItemConverter() override
virtual bool ApplyItemSet(const SfxItemSet &rItemSet) override
applies all properties that are results of a conversion from all items in rItemSet to the internal XP...
virtual bool ApplySpecialItem(sal_uInt16 nWhichId, const SfxItemSet &rItemSet) override
for items that can not be mapped directly to a property.
virtual bool GetItemProperty(tWhichIdType nWhichId, tPropertyNameWithMemberId &rOutProperty) const override
implement this method to return a Property object for a given which id.
virtual void FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet &rOutItemSet) const override
for items that can not be mapped directly to a property.
OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel > changeRegressionCurveType(SvxChartRegress eType, css::uno::Reference< css::chart2::XRegressionCurveContainer > const &xRegressionCurveContainer, css::uno::Reference< css::chart2::XRegressionCurve > const &xRegressionCurve)
OOO_DLLPUBLIC_CHARTTOOLS SvxChartRegress getRegressionType(const css::uno::Reference< css::chart2::XRegressionCurve > &xCurve)
std::shared_ptr< T > make_shared(Args &&... args)