1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CHART2_SOURCE_VIEW_CHARTTYPES_PIECHART_HXX
21 #define INCLUDED_CHART2_SOURCE_VIEW_CHARTTYPES_PIECHART_HXX
24 #include <VSeriesPlotter.hxx>
25 #include <basegfx/vector/b2ivector.hxx>
26 #include <com/sun/star/awt/Point.hpp>
30 class PiePositionHelper
;
32 class PieChart
: public VSeriesPlotter
39 PieChart( const css::uno::Reference
< css::chart2::XChartType
>& xChartTypeModel
40 , sal_Int32 nDimensionCount
, bool bExcludingPositioning
);
41 virtual ~PieChart() override
;
43 /** This method creates all shapes needed for representing the pie chart.
45 virtual void createShapes() override
;
46 virtual void rearrangeLabelToAvoidOverlapIfRequested( const css::awt::Size
& rPageSize
) override
;
48 virtual void setScales( const std::vector
< ExplicitScaleData
>& rScales
, bool bSwapXAndYAxis
) override
;
49 virtual void addSeries( std::unique_ptr
<VDataSeries
> pSeries
, sal_Int32 zSlot
, sal_Int32 xSlot
, sal_Int32 ySlot
) override
;
51 virtual css::drawing::Direction3D
getPreferredDiagramAspectRatio() const override
;
52 virtual bool shouldSnapRectToUsedArea() override
;
54 //MinimumAndMaximumSupplier
55 virtual double getMinimumX() override
;
56 virtual double getMaximumX() override
;
57 virtual double getMinimumYInRange( double fMinimumX
, double fMaximumX
, sal_Int32 nAxisIndex
) override
;
58 virtual double getMaximumYInRange( double fMinimumX
, double fMaximumX
, sal_Int32 nAxisIndex
) override
;
60 virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex
) override
;
61 virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex
) override
;
62 virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex
) override
;
63 virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex
) override
;
64 virtual bool isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIndex
) override
;
67 css::uno::Reference
<css::drawing::XShape
>
69 const css::uno::Reference
<css::drawing::XShapes
>& xTarget
,
70 const css::uno::Reference
<css::beans::XPropertySet
>& xObjectProperties
,
71 tPropertyNameValueMap
const * pOverWritePropertiesMap
,
72 const ShapeParam
& rParam
);
74 /** This method creates a text shape for a label of a data point.
77 * where to append the new created text shape.
79 * the data series, the data point belongs to.
81 * the index of the data point the label is related to.
85 void createTextLabelShape(
86 const css::uno::Reference
<css::drawing::XShapes
>& xTextTarget
,
87 VDataSeries
& rSeries
, sal_Int32 nPointIndex
, ShapeParam
& rParam
);
89 /** This method sets `m_fMaxOffset` to the maximum `Offset` property and
90 * returns it. There is a `Offset` property for each entry in a data
91 * series, moreover there exists a shared `Offset` property attached to
92 * the whole data series. The `Offset` property represents the
93 * relative distance offset of a slice from the pie center.
94 * The shared property is used for exploded pie chart, while the property
95 * attached to single data series entries is used for manual dragging of
97 * `m_fMaxOffset` is used by `PiePositionHelper::getInnerAndOuterRadius`.
98 * Note that only the `Offset` properties of the first (x slot) data series
99 * and its entries are utilized for computing the maximum offset.
101 double getMaxOffset();
102 bool detectLabelOverlapsAndMove(const css::awt::Size
& rPageSize
);//returns true when there might be more to do
103 void resetLabelPositionsToPreviousState();
105 bool tryMoveLabels( PieLabelInfo
const * pFirstBorder
, PieLabelInfo
const * pSecondBorder
106 , PieLabelInfo
* pCenter
, bool bSingleCenter
, bool& rbAlternativeMoveDirection
107 , const css::awt::Size
& rPageSize
);
109 bool performLabelBestFitInnerPlacement(ShapeParam
& rShapeParam
, PieLabelInfo
const & rPieLabelInfo
);
110 void performLabelBestFit(ShapeParam
& rShapeParam
, PieLabelInfo
const & rPieLabelInfo
);
113 std::unique_ptr
<PiePositionHelper
>
116 bool m_bSizeExcludesLabelsAndExplodedSegments
;
121 bool moveAwayFrom( const PieLabelInfo
* pFix
, const css::awt::Size
& rPageSize
122 , bool bMoveHalfWay
, bool bMoveClockwise
);
124 css::uno::Reference
< css::drawing::XShape
> xTextShape
;
125 css::uno::Reference
< css::drawing::XShape
> xLabelGroupShape
;
126 ::basegfx::B2IVector aFirstPosition
;
127 ::basegfx::B2IVector aOrigin
;
129 bool bMovementAllowed
;
131 css::uno::Reference
< css::drawing::XShapes
> xTextTarget
;
132 PieLabelInfo
* pPrevious
;
134 css::awt::Point aPreviousPosition
;
137 std::vector
< PieLabelInfo
> m_aLabelInfoList
;
139 double m_fMaxOffset
; /// cached max offset value (init'ed to NaN)
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */