23#include <unonames.hxx>
25#include <com/sun/star/chart2/DataPointLabel.hpp>
26#include <com/sun/star/chart/ChartDataCaption.hpp>
27#include <com/sun/star/beans/PropertyAttribute.hpp>
28#include <com/sun/star/beans/XPropertySet.hpp>
31using ::com::sun::star::uno::Reference;
32using ::com::sun::star::beans::Property;
40class WrappedDataCaptionProperty :
public WrappedSeriesOrDiagramProperty< sal_Int32 >
43 virtual sal_Int32 getValueFromSeries(
const css::uno::Reference< css::beans::XPropertySet >& xSeriesPropertySet )
const override;
44 virtual void setValueToSeries(
const css::uno::Reference< css::beans::XPropertySet >& xSeriesPropertySet,
const sal_Int32& aNewValue )
const override;
46 explicit WrappedDataCaptionProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
56sal_Int32 lcl_LabelToCaption(
const chart2::DataPointLabel& rLabel )
60 if( rLabel.ShowNumber )
61 nCaption |= css::chart::ChartDataCaption::VALUE;
62 if( rLabel.ShowNumberInPercent )
63 nCaption |= css::chart::ChartDataCaption::PERCENT;
64 if( rLabel.ShowCategoryName )
65 nCaption |= css::chart::ChartDataCaption::TEXT;
66 if( rLabel.ShowLegendSymbol )
67 nCaption |= css::chart::ChartDataCaption::SYMBOL;
68 if (rLabel.ShowSeriesName)
74chart2::DataPointLabel lcl_CaptionToLabel( sal_Int32 nCaption )
76 chart2::DataPointLabel
aLabel(
false,
false,
false,
false,
false,
false);
78 if( nCaption & css::chart::ChartDataCaption::VALUE )
80 if( nCaption & css::chart::ChartDataCaption::PERCENT )
81 aLabel.ShowNumberInPercent =
true;
82 if( nCaption & css::chart::ChartDataCaption::TEXT )
83 aLabel.ShowCategoryName =
true;
84 if( nCaption & css::chart::ChartDataCaption::SYMBOL )
85 aLabel.ShowLegendSymbol =
true;
86 if( nCaption & css::chart::ChartDataCaption::CUSTOM )
87 aLabel.ShowCustomLabel =
true;
89 aLabel.ShowSeriesName =
true;
94void lcl_addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
95 ,
const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact
101 rList.emplace_back(
new WrappedDataCaptionProperty( spChart2ModelContact, ePropertyType ) );
108 rOutProperties.emplace_back(
"DataCaption",
109 PROP_CHART_DATAPOINT_DATA_CAPTION,
111 beans::PropertyAttribute::BOUND
112 | beans::PropertyAttribute::MAYBEDEFAULT );
116 ,
const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
118 lcl_addWrappedProperties( rList, spChart2ModelContact,
DATA_SERIES );
122 ,
const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
124 lcl_addWrappedProperties( rList, spChart2ModelContact,
DIAGRAM );
127WrappedDataCaptionProperty::WrappedDataCaptionProperty(
128 const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact
131 ,
uno::
Any( sal_Int32(0) ), spChart2ModelContact, ePropertyType )
139 chart2::DataPointLabel
aLabel;
140 if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(
CHART_UNONAME_LABEL) >>= aLabel ) )
141 aRet = lcl_LabelToCaption( aLabel );
145void WrappedDataCaptionProperty::setValueToSeries(
const Reference< beans::XPropertySet >& xSeriesPropertySet,
const sal_Int32& nCaption )
const
147 if(!xSeriesPropertySet.is())
150 chart2::DataPointLabel
aLabel = lcl_CaptionToLabel( nCaption );
css::uno::Any m_aDefaultValue
static void addWrappedPropertiesForSeries(std::vector< std::unique_ptr< WrappedProperty > > &rList, const std::shared_ptr< Chart2ModelContact > &spChart2ModelContact)
static void addWrappedPropertiesForDiagram(std::vector< std::unique_ptr< WrappedProperty > > &rList, const std::shared_ptr< Chart2ModelContact > &spChart2ModelContact)
static void addProperties(std::vector< css::beans::Property > &rOutProperties)
tSeriesOrDiagramPropertyType
@ FAST_PROPERTY_ID_START_CHART_DATACAPTION_PROP
constexpr OUStringLiteral CHART_UNONAME_LABEL