26#include <unonames.hxx>
30#include <com/sun/star/chart2/CurveStyle.hpp>
31#include <com/sun/star/beans/PropertyAttribute.hpp>
32#include <com/sun/star/beans/XPropertySet.hpp>
36using ::com::sun::star::uno::Any;
37using ::com::sun::star::beans::Property;
47template<
typename PROPERTYTYPE >
48class WrappedSplineProperty :
public WrappedProperty
51 explicit WrappedSplineProperty(
const OUString& rOuterName, OUString aInnerName
52 ,
const css::uno::Any& rDefaulValue
53 , std::shared_ptr<Chart2ModelContact> spChart2ModelContact )
54 : WrappedProperty(rOuterName,OUString())
62 bool detectInnerValue( PROPERTYTYPE& rValue,
bool& rHasAmbiguousValue )
const
64 rHasAmbiguousValue =
false;
68 bool bHasDetectableInnerValue =
false;
69 std::vector< rtl::Reference< ChartType > > aChartTypes = xDiagram->getChartTypes();
70 for( sal_Int32 nN = aChartTypes.size(); nN--; )
75 PROPERTYTYPE aCurValue = PROPERTYTYPE();
76 aSingleValue >>= aCurValue;
77 if( !bHasDetectableInnerValue )
81 if( rValue != aCurValue )
83 rHasAmbiguousValue =
true;
89 bHasDetectableInnerValue =
true;
91 catch( uno::Exception & ex )
98 return bHasDetectableInnerValue;
100 void setPropertyValue(
const css::uno::Any& rOuterValue,
const css::uno::Reference< css::beans::XPropertySet >& )
const override
102 PROPERTYTYPE aNewValue;
103 if( ! (rOuterValue >>= aNewValue) )
104 throw css::lang::IllegalArgumentException(
"spline property requires different type",
nullptr, 0 );
108 bool bHasAmbiguousValue =
false;
109 PROPERTYTYPE aOldValue = PROPERTYTYPE();
110 if( !detectInnerValue( aOldValue, bHasAmbiguousValue ) )
113 if( !(bHasAmbiguousValue || aNewValue != aOldValue) )
116 std::vector< rtl::Reference< ChartType > > aChartTypes =
118 for( sal_Int32 nN = aChartTypes.size(); nN--; )
124 catch( uno::Exception & ex )
133 css::uno::Any
getPropertyValue(
const css::uno::Reference< css::beans::XPropertySet >& )
const override
135 bool bHasAmbiguousValue =
false;
137 if( detectInnerValue( aValue, bHasAmbiguousValue ) )
144 css::uno::Any getPropertyDefault(
const css::uno::Reference< css::beans::XPropertyState >& )
const override
157class WrappedSplineTypeProperty :
public WrappedSplineProperty< sal_Int32 >
160 explicit WrappedSplineTypeProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
162 virtual css::uno::Any convertInnerToOuterValue(
const css::uno::Any& rInnerValue )
const override;
163 virtual css::uno::Any convertOuterToInnerValue(
const css::uno::Any& rOuterValue )
const override;
170 , PROP_CHART_SPLINE_ORDER
171 , PROP_CHART_SPLINE_RESOLUTION
179 PROP_CHART_SPLINE_TYPE,
181 beans::PropertyAttribute::BOUND
182 | beans::PropertyAttribute::MAYBEDEFAULT
183 | beans::PropertyAttribute::MAYBEVOID );
185 PROP_CHART_SPLINE_ORDER,
187 beans::PropertyAttribute::BOUND
188 | beans::PropertyAttribute::MAYBEDEFAULT
189 | beans::PropertyAttribute::MAYBEVOID );
191 PROP_CHART_SPLINE_RESOLUTION,
193 beans::PropertyAttribute::BOUND
194 | beans::PropertyAttribute::MAYBEDEFAULT
195 | beans::PropertyAttribute::MAYBEVOID );
199 ,
const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
201 rList.emplace_back(
new WrappedSplineTypeProperty( spChart2ModelContact ) );
203 new WrappedSplineProperty<sal_Int32>(
205 uno::Any(sal_Int32(3)), spChart2ModelContact));
207 new WrappedSplineProperty<sal_Int32>(
209 uno::Any(sal_Int32(20)), spChart2ModelContact));
212WrappedSplineTypeProperty::WrappedSplineTypeProperty(
const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
217Any WrappedSplineTypeProperty::convertInnerToOuterValue(
const Any& rInnerValue )
const
219 chart2::CurveStyle aInnerValue = chart2::CurveStyle_LINES;
220 rInnerValue >>= aInnerValue;
222 sal_Int32 nOuterValue;
225 case chart2::CurveStyle_CUBIC_SPLINES:
228 case chart2::CurveStyle_B_SPLINES:
231 case chart2::CurveStyle_STEP_START:
234 case chart2::CurveStyle_STEP_END:
237 case chart2::CurveStyle_STEP_CENTER_X:
240 case chart2::CurveStyle_STEP_CENTER_Y:
249Any WrappedSplineTypeProperty::convertOuterToInnerValue(
const Any& rOuterValue )
const
251 sal_Int32 nOuterValue=0;
252 rOuterValue >>= nOuterValue;
254 chart2::CurveStyle aInnerValue;
259 aInnerValue = chart2::CurveStyle_CUBIC_SPLINES;
262 aInnerValue = chart2::CurveStyle_B_SPLINES;
265 aInnerValue = chart2::CurveStyle_STEP_START;
268 aInnerValue = chart2::CurveStyle_STEP_END;
271 aInnerValue = chart2::CurveStyle_STEP_CENTER_X;
274 aInnerValue = chart2::CurveStyle_STEP_CENTER_Y;
277 SAL_WARN_IF(nOuterValue != 0,
"chart2",
"Unknown line style");
278 aInnerValue = chart2::CurveStyle_LINES;
const OUString m_aOwnInnerName
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
css::uno::Any m_aOuterValue
css::uno::Any m_aDefaultValue
static void addProperties(std::vector< css::beans::Property > &rOutProperties)
static void addWrappedProperties(std::vector< std::unique_ptr< WrappedProperty > > &rList, const std::shared_ptr< Chart2ModelContact > &spChart2ModelContact)
#define SAL_WARN_IF(condition, area, stream)
void setPropertyValue(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Set a property to a certain value in the given map.
@ FAST_PROPERTY_ID_START_CHART_SPLINE_PROP
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
constexpr OUStringLiteral CHART_UNONAME_SPLINE_RESOLUTION
constexpr OUStringLiteral CHART_UNONAME_SPLINE_ORDER
constexpr OUStringLiteral CHART_UNONAME_CURVE_STYLE
constexpr OUStringLiteral CHART_UNONAME_CURVE_RESOLUTION
constexpr OUStringLiteral CHART_UNONAME_SPLINE_TYPE