28#include <rtl/math.hxx>
30#include <com/sun/star/chart2/XInternalDataProvider.hpp>
31#include <com/sun/star/chart2/XChartDocument.hpp>
32#include <com/sun/star/chart/ErrorBarStyle.hpp>
41void lcl_getErrorValues(
const uno::Reference< beans::XPropertySet > & xErrorBarProp,
42 double & rOutPosError,
double & rOutNegError )
44 if( ! xErrorBarProp.is())
49 xErrorBarProp->getPropertyValue(
"PositiveError" ) >>= rOutPosError;
50 xErrorBarProp->getPropertyValue(
"NegativeError" ) >>= rOutNegError;
52 catch(
const uno::Exception & )
58void lcl_getErrorIndicatorValues(
59 const uno::Reference< beans::XPropertySet > & xErrorBarProp,
60 bool & rOutShowPosError,
bool & rOutShowNegError )
62 if( ! xErrorBarProp.is())
67 xErrorBarProp->getPropertyValue(
"ShowPositiveError" ) >>= rOutShowPosError;
68 xErrorBarProp->getPropertyValue(
"ShowNegativeError" ) >>= rOutShowNegError;
70 catch(
const uno::Exception & )
89 rPropertySet, rItemPool, rDrawModel,
90 xNamedPropertyContainerFactory,
128 sal_uInt16 nWhichId,
const SfxItemSet & rItemSet )
130 bool bChanged =
false;
145 if( !xErrorBarProp.is() && eErrorKind == SvxChartKindError::NONE)
151 sal_Int32 nStyle = css::chart::ErrorBarStyle::NONE;
155 case SvxChartKindError::NONE:
156 nStyle = css::chart::ErrorBarStyle::NONE;
break;
157 case SvxChartKindError::Variant:
158 nStyle = css::chart::ErrorBarStyle::VARIANCE;
break;
159 case SvxChartKindError::Sigma:
160 nStyle = css::chart::ErrorBarStyle::STANDARD_DEVIATION;
break;
161 case SvxChartKindError::Percent:
162 nStyle = css::chart::ErrorBarStyle::RELATIVE;
break;
163 case SvxChartKindError::BigError:
164 nStyle = css::chart::ErrorBarStyle::ERROR_MARGIN;
break;
165 case SvxChartKindError::Const:
166 nStyle = css::chart::ErrorBarStyle::ABSOLUTE;
break;
167 case SvxChartKindError::StdError:
168 nStyle = css::chart::ErrorBarStyle::STANDARD_ERROR;
break;
169 case SvxChartKindError::Range:
170 nStyle = css::chart::ErrorBarStyle::FROM_DATA;
break;
173 xErrorBarProp->setPropertyValue(
"ErrorBarStyle" ,
uno::Any( nStyle ));
182 OSL_FAIL(
"Deprecated item" );
188 double fPos(0.0), fNeg(0.0);
189 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
191 if( ! ( ::rtl::math::approxEqual( fPos, fValue ) &&
192 ::rtl::math::approxEqual( fNeg, fValue )))
194 xErrorBarProp->setPropertyValue(
"PositiveError" ,
uno::Any( fValue ));
195 xErrorBarProp->setPropertyValue(
"NegativeError" ,
uno::Any( fValue ));
206 double fPos(0.0), fNeg(0.0);
209 if( ! ::rtl::math::approxEqual( fPos, fValue ))
224 double fPos(0.0), fNeg(0.0);
225 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
227 if( ! ::rtl::math::approxEqual( fNeg, fValue ))
229 xErrorBarProp->setPropertyValue(
"NegativeError" ,
uno::Any( fValue ));
243 bool bNewIndPos = (eIndicate == SvxChartIndicate::Both || eIndicate == SvxChartIndicate::Up );
244 bool bNewIndNeg = (eIndicate == SvxChartIndicate::Both || eIndicate == SvxChartIndicate::Down );
246 bool bShowPos(
false), bShowNeg(
false);
247 lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
249 if( bShowPos != bNewIndPos ||
250 bShowNeg != bNewIndNeg )
252 xErrorBarProp->setPropertyValue(
"ShowPositiveError" ,
uno::Any( bNewIndPos ));
253 xErrorBarProp->setPropertyValue(
"ShowNegativeError" ,
uno::Any( bNewIndNeg ));
271 xDataProvider.set( xChartDoc->getDataProvider());
272 if( xErrorBarSource.is() && xDataProvider.is())
275 bool bApplyNewRange =
false;
278 if( xChartDoc->hasInternalDataProvider())
280 if( !aNewRange.isEmpty())
284 xErrorBarSource, bIsPositiveValue, bYError ));
289 OSL_ASSERT( xIntDataProvider.is());
290 if( xIntDataProvider.is())
292 xIntDataProvider->appendSequence();
294 bApplyNewRange =
true;
303 xErrorBarSource, bIsPositiveValue, bYError ));
305 ! ( xSeq.is() && (aNewRange == xSeq->getSourceRangeRepresentation()));
310 xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError );
320 sal_uInt16 nWhichId,
SfxItemSet & rOutItemSet )
const
329 sal_Int32 nStyle = 0;
330 if( xErrorBarProp->getPropertyValue(
"ErrorBarStyle" ) >>= nStyle )
334 case css::chart::ErrorBarStyle::NONE:
336 case css::chart::ErrorBarStyle::VARIANCE:
337 eErrorKind = SvxChartKindError::Variant;
break;
338 case css::chart::ErrorBarStyle::STANDARD_DEVIATION:
339 eErrorKind = SvxChartKindError::Sigma;
break;
340 case css::chart::ErrorBarStyle::ABSOLUTE:
341 eErrorKind = SvxChartKindError::Const;
break;
342 case css::chart::ErrorBarStyle::RELATIVE:
343 eErrorKind = SvxChartKindError::Percent;
break;
344 case css::chart::ErrorBarStyle::ERROR_MARGIN:
345 eErrorKind = SvxChartKindError::BigError;
break;
346 case css::chart::ErrorBarStyle::STANDARD_ERROR:
347 eErrorKind = SvxChartKindError::StdError;
break;
348 case css::chart::ErrorBarStyle::FROM_DATA:
349 eErrorKind = SvxChartKindError::Range;
break;
358 double fPos(0.0), fNeg(0.0);
366 double fPos(0.0), fNeg(0.0);
374 double fPos(0.0), fNeg(0.0);
382 double fPos(0.0), fNeg(0.0);
391 bool bShowPos(
false), bShowNeg(
false);
392 lcl_getErrorIndicatorValues(
GetPropertySet(), bShowPos, bShowNeg );
397 eIndicate = SvxChartIndicate::Both;
399 eIndicate = SvxChartIndicate::Up;
404 eIndicate = SvxChartIndicate::Down;
406 eIndicate = SvxChartIndicate::NONE;
419 if( xErrorBarSource.is())
425 rOutItemSet.
Put(
SfxStringItem( nWhichId, xSeq->getSourceRangeRepresentation()));
constexpr TypedWhichId< SfxStringItem > SCHATTR_STAT_RANGE_POS(SCHATTR_STAT_START+7)
constexpr TypedWhichId< SvxChartIndicateItem > SCHATTR_STAT_INDICATE(SCHATTR_STAT_START+6)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_STAT_ERRORBAR_TYPE(SCHATTR_STAT_START+9)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_STAT_BIGERROR(SCHATTR_STAT_START+3)
constexpr TypedWhichId< SvxChartKindErrorItem > SCHATTR_STAT_KIND_ERROR(SCHATTR_STAT_START+1)
constexpr TypedWhichId< SfxStringItem > SCHATTR_STAT_RANGE_NEG(SCHATTR_STAT_START+8)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_STAT_CONSTPLUS(SCHATTR_STAT_START+4)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_STAT_CONSTMINUS(SCHATTR_STAT_START+5)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_STAT_PERCENT(SCHATTR_STAT_START+2)
const WhichRangesContainer nErrorBarWhichPairs(svl::Items< SCHATTR_STAT_START, SCHATTR_STAT_END, XATTR_LINE_FIRST, XATTR_LINE_LAST >)
const OUString & GetValue() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
ErrorBarItemConverter(css::uno::Reference< css::frame::XModel > xChartModel, const css::uno::Reference< css::beans::XPropertySet > &rPropertySet, SfxItemPool &rItemPool, SdrModel &rDrawModel, const css::uno::Reference< css::lang::XMultiServiceFactory > &xNamedPropertyContainerFactory)
css::uno::Reference< css::frame::XModel > m_xModel
virtual bool GetItemProperty(tWhichIdType nWhichId, tPropertyNameWithMemberId &rOutProperty) const override
implement this method to return a Property object for a given which id.
virtual bool ApplySpecialItem(sal_uInt16 nWhichId, const SfxItemSet &rItemSet) override
for items that can not be mapped directly to a property.
virtual void FillItemSet(SfxItemSet &rOutItemSet) const override
applies all properties that can be mapped to items into the given item set.
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 const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
std::shared_ptr< ItemConverter > m_spGraphicConverter
virtual ~ErrorBarItemConverter() override
virtual void FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet &rOutItemSet) const override
for items that can not be mapped directly to a property.
This class serves for conversion between properties of an XPropertySet and SfxItems in SfxItemSets.
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...
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< frame::XModel > m_xModel
OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XDataSequence > getErrorDataSequenceFromDataSource(const css::uno::Reference< css::chart2::data::XDataSource > &xDataSource, bool bPositiveValue, bool bYError=true)
OOO_DLLPUBLIC_CHARTTOOLS void setErrorDataSequence(const css::uno::Reference< css::chart2::data::XDataSource > &xDataSource, const css::uno::Reference< css::chart2::data::XDataProvider > &xDataProvider, const OUString &rNewRange, bool bPositiveValue, bool bYError=true, OUString const *pXMLRange=nullptr)
std::shared_ptr< T > make_shared(Args &&... args)
Reference< XModel > xModel