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
23 #include "VSeriesPlotter.hxx"
24 #include <basegfx/vector/b2dvector.hxx>
25 #include <basegfx/range/b2irectangle.hxx>
29 class PiePositionHelper
;
31 class PieChart
: public VSeriesPlotter
36 PieChart( const ::com::sun::star::uno::Reference
<
37 ::com::sun::star::chart2::XChartType
>& xChartTypeModel
38 , sal_Int32 nDimensionCount
, bool bExcludingPositioning
);
41 /** This method creates all shapes needed for representing the pie chart.
43 virtual void createShapes() SAL_OVERRIDE
;
44 virtual void rearrangeLabelToAvoidOverlapIfRequested( const ::com::sun::star::awt::Size
& rPageSize
) SAL_OVERRIDE
;
46 virtual void setScales( const ::std::vector
< ExplicitScaleData
>& rScales
, bool bSwapXAndYAxis
) SAL_OVERRIDE
;
47 virtual void addSeries( VDataSeries
* pSeries
, sal_Int32 zSlot
= -1, sal_Int32 xSlot
= -1,sal_Int32 ySlot
= -1 ) SAL_OVERRIDE
;
49 virtual ::com::sun::star::drawing::Direction3D
getPreferredDiagramAspectRatio() const SAL_OVERRIDE
;
50 virtual bool keepAspectRatio() const SAL_OVERRIDE
;
51 virtual bool shouldSnapRectToUsedArea() SAL_OVERRIDE
;
53 //MinimumAndMaximumSupplier
54 virtual double getMinimumX() SAL_OVERRIDE
;
55 virtual double getMaximumX() SAL_OVERRIDE
;
56 virtual double getMinimumYInRange( double fMinimumX
, double fMaximumX
, sal_Int32 nAxisIndex
) SAL_OVERRIDE
;
57 virtual double getMaximumYInRange( double fMinimumX
, double fMaximumX
, sal_Int32 nAxisIndex
) SAL_OVERRIDE
;
59 virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex
) SAL_OVERRIDE
;
60 virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex
) SAL_OVERRIDE
;
61 virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex
) SAL_OVERRIDE
;
62 virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex
) SAL_OVERRIDE
;
63 virtual bool isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIndex
) SAL_OVERRIDE
;
66 //no default constructor
69 css::uno::Reference
<css::drawing::XShape
>
71 const css::uno::Reference
<css::drawing::XShapes
>& xTarget
,
72 const css::uno::Reference
<css::beans::XPropertySet
>& xObjectProperties
,
73 tPropertyNameValueMap
* pOverWritePropertiesMap
,
74 const ShapeParam
& rParam
);
76 /** This method creates a text shape for a label of a data point.
79 * where to append the new created text shape.
81 * the data series, the data point belongs to.
83 * the index of the data point the label is related to.
87 void createTextLabelShape(
88 const css::uno::Reference
<css::drawing::XShapes
>& xTextTarget
,
89 VDataSeries
& rSeries
, sal_Int32 nPointIndex
, ShapeParam
& rParam
);
91 /** This method sets `m_fMaxOffset` to the maximum `Offset` property and
92 * returns it. There is a `Offset` property for each entry in a data
93 * series, moreover there exists a shared `Offset` property attached to
94 * the whole data series. The `Offset` property represents the
95 * relative distance offset of a slice from the pie center.
96 * The shared property is used for exploded pie chart, while the property
97 * attached to single data series entries is used for manual dragging of
99 * `m_fMaxOffset` is used by `PiePositionHelper::getInnerAndOuterRadius`.
100 * Note that only the `Offset` properties of the first (x slot) data series
101 * and its entries are utilized for computing the maximum offset.
103 double getMaxOffset();
104 bool detectLabelOverlapsAndMove(const ::com::sun::star::awt::Size
& rPageSize
);//returns true when there might be more to do
105 void resetLabelPositionsToPreviousState();
107 bool tryMoveLabels( PieLabelInfo
* pFirstBorder
, PieLabelInfo
* pSecondBorder
108 , PieLabelInfo
* pCenter
, bool bSingleCenter
, bool& rbAlternativeMoveDirection
109 , const ::com::sun::star::awt::Size
& rPageSize
);
111 bool performLabelBestFitInnerPlacement(ShapeParam
& rShapeParam
, PieLabelInfo
& rPieLabelInfo
);
112 static bool performLabelBestFitOuterPlacement(ShapeParam
& rShapeParam
, PieLabelInfo
& rPieLabelInfo
);
113 void performLabelBestFit(ShapeParam
& rShapeParam
, PieLabelInfo
& rPieLabelInfo
);
116 PiePositionHelper
* m_pPosHelper
;
118 bool m_bSizeExcludesLabelsAndExplodedSegments
;
123 bool moveAwayFrom( const PieLabelInfo
* pFix
, const ::com::sun::star::awt::Size
& rPageSize
124 , bool bMoveHalfWay
, bool bMoveClockwise
, bool bAlternativeMoveDirection
);
126 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> xTextShape
;
127 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> xLabelGroupShape
;
128 ::basegfx::B2IVector aFirstPosition
;
129 ::basegfx::B2IVector aOrigin
;
131 bool bMovementAllowed
;
133 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
> xTextTarget
;
134 PieLabelInfo
* pPrevious
;
136 ::com::sun::star::awt::Point aPreviousPosition
;
139 ::std::vector
< PieLabelInfo
> m_aLabelInfoList
;
141 double m_fMaxOffset
; /// cached max offset value (init'ed to NaN)
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */