34#include <com/sun/star/beans/PropertyAttribute.hpp>
35#include <com/sun/star/drawing/LineStyle.hpp>
36#include <com/sun/star/uno/XComponentContext.hpp>
37#include <officecfg/Office/Compatibility.hxx>
40#include <rtl/math.hxx>
47using ::com::sun::star::beans::Property;
48using ::com::sun::star::uno::Sequence;
49using ::com::sun::star::uno::Reference;
56 PROP_PIE_TEMPLATE_DEFAULT_OFFSET,
57 PROP_PIE_TEMPLATE_OFFSET_MODE,
58 PROP_PIE_TEMPLATE_DIMENSION,
59 PROP_PIE_TEMPLATE_USE_RINGS
68 ::chart::PropertyHelper::setPropertyValueDefault< double >( aOutMap, PROP_PIE_TEMPLATE_DEFAULT_OFFSET, 0.5 );
69 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_PIE_TEMPLATE_DIMENSION, 2 );
73 return aStaticDefaults;
78 static ::cppu::OPropertyArrayHelper aPropHelper(
83 PROP_PIE_TEMPLATE_OFFSET_MODE,
85 beans::PropertyAttribute::BOUND
86 | beans::PropertyAttribute::MAYBEDEFAULT },
88 PROP_PIE_TEMPLATE_DEFAULT_OFFSET,
90 beans::PropertyAttribute::BOUND
91 | beans::PropertyAttribute::MAYBEDEFAULT },
93 PROP_PIE_TEMPLATE_DIMENSION,
95 beans::PropertyAttribute::BOUND
96 | beans::PropertyAttribute::MAYBEDEFAULT },
98 PROP_PIE_TEMPLATE_USE_RINGS,
100 beans::PropertyAttribute::BOUND
101 | beans::PropertyAttribute::MAYBEDEFAULT } };
111uno::Reference< beans::XPropertySetInfo >& StaticPieChartTypeTemplateInfo()
113 static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
115 return xPropertySetInfo;
125 uno::XComponentContext >
const & xContext,
126 const OUString & rServiceName,
127 chart2::PieChartOffsetMode eMode,
144 tPropertyValueMap::const_iterator aFound( rStaticDefaults.find(
nHandle ) );
145 if( aFound == rStaticDefaults.end() )
148 rAny = (*aFound).second;
153 return StaticPieChartTypeTemplateInfoHelper();
159 return StaticPieChartTypeTemplateInfo();
172 catch(
const beans::UnknownPropertyException & )
210 chart2::ScaleData aScaleData( xAxis->getScaleData() );
213 if (!officecfg::Office::Compatibility::View::ClockwisePieChartDirection::get())
215 aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
219 aScaleData.Orientation = chart2::AxisOrientation_REVERSE;
221 xAxis->setScaleData( aScaleData );
228 chart2::ScaleData aScaleData( xAxis->getScaleData() );
231 if( officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get() )
232 aScaleData.Orientation = chart2::AxisOrientation_REVERSE;
234 aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
235 xAxis->setScaleData( aScaleData );
238 catch(
const uno::Exception & )
250 if( rCoordSys.empty() )
256 xCT->setFastPropertyValue(
258 rCoordSys[0]->setChartTypes( std::vector{xCT} );
260 if( !aSeriesSeq.empty() )
262 std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq =
FlattenSequence( aSeriesSeq );
263 xCT->setDataSeries( aFlatSeriesSeq );
269 catch(
const uno::Exception & )
278 bool bAdaptProperties )
282 bool bTemplateUsesRings =
false;
284 chart2::PieChartOffsetMode ePieOffsetMode;
293 bool bAllOffsetsEqual =
true;
294 sal_Int32 nOuterSeriesIndex = 0;
296 std::vector< rtl::Reference< DataSeries > > aSeriesVec =
297 xDiagram->getDataSeries();
300 if( !officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get() )
301 nOuterSeriesIndex = aSeriesVec.size() - 1;
304 if( !aSeriesVec.empty() )
308 xSeries->getPropertyValue(
"Offset") >>= fOffset;
314 for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
319 double fPointOffset=0.0;
320 if( xSeries->getPropertyValue(
"Offset") >>= fPointOffset )
322 if( ! ::rtl::math::approxEqual( fPointOffset, fOffset ) )
324 bAllOffsetsEqual =
false;
333 chart2::PieChartOffsetMode eOffsetMode = chart2::PieChartOffsetMode_NONE;
334 if( bAllOffsetsEqual && fOffset > 0.0 )
336 eOffsetMode = chart2::PieChartOffsetMode_ALL_EXPLODED;
337 if( bAdaptProperties )
341 bResult = ( eOffsetMode == ePieOffsetMode );
343 catch(
const uno::Exception & )
354 bool bUseRings =
false;
357 bResult = ( bTemplateUsesRings == bUseRings );
371 xResult->setFastPropertyValue(
374 catch(
const uno::Exception & )
391 xResult->setFastPropertyValue(
394 catch(
const uno::Exception & )
404 ::sal_Int32 nChartTypeIndex,
405 ::sal_Int32 nSeriesIndex,
406 ::sal_Int32 nSeriesCount )
412 bool bTemplateUsesRings =
false;
413 sal_Int32 nOuterSeriesIndex = 0;
417 if( !officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get() )
418 nOuterSeriesIndex = nSeriesCount - 1;
420 if( nSeriesIndex == nOuterSeriesIndex )
422 static constexpr OUStringLiteral aOffsetPropName(
u"Offset" );
424 chart2::PieChartOffsetMode ePieOffsetMode;
428 double fDefaultOffset = 0.5;
430 double fOffsetToSet = fDefaultOffset;
437 bool bSetOffset = ( ePieOffsetMode == chart2::PieChartOffsetMode_ALL_EXPLODED );
439 (ePieOffsetMode == chart2::PieChartOffsetMode_NONE) )
443 double fOffset = 0.0;
444 if( (xSeries->getPropertyValue( aOffsetPropName ) >>= fOffset) &&
445 ::rtl::math::approxEqual( fOffset, fDefaultOffset ))
449 for(
auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) )
452 xSeries->getDataPointByIndex( pointIndex ));
454 double fPointOffset = 0.0;
455 if( xPointState.is() &&
456 (xPointState->getPropertyState( aOffsetPropName ) == beans::PropertyState_DIRECT_VALUE) &&
458 (xPointProp->getPropertyValue( aOffsetPropName ) >>= fPointOffset ) &&
459 ! ::rtl::math::approxEqual( fPointOffset, fDefaultOffset ) )
471 xSeries->setPropertyValue( aOffsetPropName,
uno::Any( fOffsetToSet ));
474 for(
auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) )
477 xSeries->getDataPointByIndex( pointIndex ), uno::UNO_QUERY );
478 if( xPointState.is())
479 xPointState->setPropertyToDefault( aOffsetPropName );
490 catch(
const uno::Exception & )
501 const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysSeq( xDiagram->getBaseCoordinateSystems());
513 chart2::ScaleData aScaleData( xAxis->getScaleData() );
514 aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
515 xAxis->setScaleData( aScaleData );
521 chart2::ScaleData aScaleData( xAxis->getScaleData() );
522 aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
523 xAxis->setScaleData( aScaleData );
526 catch(
const uno::Exception & )
537 std::vector< rtl::Reference< DataSeries > > aSeriesVec =
538 xDiagram->getDataSeries();
539 uno::Any aLineStyleAny( drawing::LineStyle_NONE );
540 for (
auto const& series : aSeriesVec)
542 series->setPropertyToDefault(
"VaryColorsByPoint");
543 if( series->getPropertyValue(
"BorderStyle") == aLineStyleAny )
545 series->setPropertyToDefault(
"BorderStyle");
550 xDiagram->setDefaultRotation(
false );
560 xDiagram->setDefaultRotation(
true );
PropertiesInfo aProperties
static rtl::Reference< ::chart::Axis > getAxis(sal_Int32 nDimensionIndex, bool bMainAxis, const rtl::Reference< ::chart::Diagram > &xDiagram)
static void removeExplicitScaling(css::chart2::ScaleData &rScaleData)
For creating diagrams and modifying existing diagrams.
virtual bool matchesTemplate2(const rtl::Reference< ::chart::Diagram > &xDiagram, bool bAdaptProperties)
void createAxes(const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > &rCoordSys)
create axes and add them to the given container.
virtual StackMode getStackMode(sal_Int32 nChartTypeIndex) const
returns StackMode::NONE by default.
virtual void adaptScales(const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > &aCooSysSeq, const css::uno::Reference< css::chart2::data::XLabeledDataSequence > &xCategories)
Sets categories at the scales of dimension 0 and the percent stacking at the scales of dimension 1 of...
static void copyPropertiesFromOldToNewCoordinateSystem(const std::vector< rtl::Reference< ChartType > > &rOldChartTypesSeq, const rtl::Reference< ChartType > &xNewChartType)
virtual void applyStyle2(const rtl::Reference< ::chart::DataSeries > &xSeries, ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount)
virtual void resetStyles2(const rtl::Reference< ::chart::Diagram > &xDiagram)
virtual void adaptDiagram(const rtl::Reference< ::chart::Diagram > &xDiagram) override
Allows derived classes to manipulate the diagrams whole, like changing the wall color.
virtual sal_Int32 getAxisCountByDimension(sal_Int32 nDimension) override
Give the number of requested axis per dimension here.
virtual void createChartTypes(const std::vector< std::vector< rtl::Reference< ::chart::DataSeries > > > &aSeriesSeq, const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > &rCoordSys, const std::vector< rtl::Reference< ChartType > > &aOldChartTypesSeq) override
create a data series tree, that fits the requirements of the chart type.
PieChartTypeTemplate(css::uno::Reference< css::uno::XComponentContext > const &xContext, const OUString &rServiceName, css::chart2::PieChartOffsetMode eMode, bool bRings, sal_Int32 nDim=2)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual rtl::Reference< ::chart::ChartType > getChartTypeForIndex(sal_Int32 nChartTypeIndex) override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
The InfoHelper table contains all property names and types of this object.
virtual void resetStyles2(const rtl::Reference< ::chart::Diagram > &xDiagram) override
virtual rtl::Reference< ::chart::ChartType > getChartTypeForNewSeries2(const std::vector< rtl::Reference< ::chart::ChartType > > &aFormerlyUsedChartTypes) override
virtual void adaptAxes(const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > &rCoordSys) override
adapt properties of existing axes and remove superfluous axes
virtual sal_Int32 getDimension() const override
returns 2 by default. Supported are 2 and 3
virtual ~PieChartTypeTemplate() override
virtual void adaptScales(const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > &aCooSysSeq, const css::uno::Reference< css::chart2::data::XLabeledDataSequence > &xCategories) override
Sets categories at the scales of dimension 0 and the percent stacking at the scales of dimension 1 of...
virtual void applyStyle2(const rtl::Reference< ::chart::DataSeries > &xSeries, ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex, ::sal_Int32 nSeriesCount) override
virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any &rAny) const override
merge XInterface implementations
virtual bool matchesTemplate2(const rtl::Reference< ::chart::Diagram > &xDiagram, bool bAdaptProperties) override
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
css::uno::Type const & get()
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
The same as getFastPropertyValue, but return the value through rValue and nHandle is always valid.
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
The same as setFastPropertyValue; nHandle is always valid.
#define DBG_UNHANDLED_EXCEPTION(...)
OOO_DLLPUBLIC_CHARTTOOLS void setStackModeAtSeries(const std::vector< rtl::Reference< ::chart::DataSeries > > &aSeries, const rtl::Reference< ::chart::BaseCoordinateSystem > &xCorrespondingCoordinateSystem, StackMode eStackMode)
OOO_DLLPUBLIC_CHARTTOOLS void setPropertyAlsoToAllAttributedDataPoints(const rtl::Reference< ::chart::DataSeries > &xSeries, const OUString &rPropertyName, const css::uno::Any &rPropertyValue)
@ PROP_DATASERIES_ATTRIBUTED_DATA_POINTS
@ PROP_DATASERIES_VARY_COLORS_BY_POINT
void setPropertyValueDefault(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Calls setPropertyValue() but asserts that the given property hasn't been set before.
std::unordered_map< tPropertyValueMapKey, css::uno::Any > tPropertyValueMap
@ PROP_PIECHARTTYPE_USE_RINGS
std::vector< T > FlattenSequence(const std::vector< std::vector< T > > &aSeqSeq)
std::vector< std::vector< T > > -> std::vector< T >
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)