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 _CHART2_PIECHART_HXX
21 #define _CHART2_PIECHART_HXX
23 #include "VSeriesPlotter.hxx"
24 #include <basegfx/vector/b2dvector.hxx>
25 #include <basegfx/range/b2irectangle.hxx>
27 //.............................................................................
30 //.............................................................................
31 class PiePositionHelper
;
33 class PieChart
: public VSeriesPlotter
35 //-------------------------------------------------------------------------
37 //-------------------------------------------------------------------------
39 PieChart( const ::com::sun::star::uno::Reference
<
40 ::com::sun::star::chart2::XChartType
>& xChartTypeModel
41 , sal_Int32 nDimensionCount
, bool bExcludingPositioning
);
44 virtual void createShapes();
45 virtual void rearrangeLabelToAvoidOverlapIfRequested( const ::com::sun::star::awt::Size
& rPageSize
);
47 virtual void setScales( const ::std::vector
< ExplicitScaleData
>& rScales
, bool bSwapXAndYAxis
);
48 virtual void addSeries( VDataSeries
* pSeries
, sal_Int32 zSlot
= -1, sal_Int32 xSlot
= -1,sal_Int32 ySlot
= -1 );
51 virtual ::com::sun::star::drawing::Direction3D
getPreferredDiagramAspectRatio() const;
52 virtual bool keepAspectRatio() const;
53 virtual bool shouldSnapRectToUsedArea();
55 //MinimumAndMaximumSupplier
56 virtual double getMinimumX();
57 virtual double getMaximumX();
58 virtual double getMinimumYInRange( double fMinimumX
, double fMaximumX
, sal_Int32 nAxisIndex
);
59 virtual double getMaximumYInRange( double fMinimumX
, double fMaximumX
, sal_Int32 nAxisIndex
);
61 virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex
);
62 virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex
);
63 virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex
);
64 virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex
);
65 virtual bool isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIndex
);
67 //-------------------------------------------------------------------------
68 //-------------------------------------------------------------------------
69 //-------------------------------------------------------------------------
71 //no default constructor
74 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>
75 createDataPoint( const ::com::sun::star::uno::Reference
<
76 ::com::sun::star::drawing::XShapes
>& xTarget
77 , const ::com::sun::star::uno::Reference
<
78 ::com::sun::star::beans::XPropertySet
>& xObjectProperties
79 , double fUnitCircleStartAngleDegree
, double fWidthAngleDegree
80 , double fUnitCircleInnerRadius
, double fUnitCircleOuterRadius
81 , double fLogicZ
, double fDepth
, double fExplodePercentage
82 , tPropertyNameValueMap
* pOverWritePropertiesMap
);
84 double getMaxOffset();
85 bool detectLabelOverlapsAndMove(const ::com::sun::star::awt::Size
& rPageSize
);//returns true when there might be more to do
86 void resetLabelPositionsToPreviousState();
88 bool tryMoveLabels( PieLabelInfo
* pFirstBorder
, PieLabelInfo
* pSecondBorder
89 , PieLabelInfo
* pCenter
, bool bSingleCenter
, bool& rbAlternativeMoveDirection
90 , const ::com::sun::star::awt::Size
& rPageSize
);
93 PiePositionHelper
* m_pPosHelper
;
95 bool m_bSizeExcludesLabelsAndExplodedSegments
;
100 bool moveAwayFrom( const PieLabelInfo
* pFix
, const ::com::sun::star::awt::Size
& rPageSize
101 , bool bMoveHalfWay
, bool bMoveClockwise
, bool bAlternativeMoveDirection
);
103 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> xTextShape
;
104 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> xLabelGroupShape
;
105 ::basegfx::B2IVector aFirstPosition
;
106 ::basegfx::B2IVector aOrigin
;
108 bool bMovementAllowed
;
110 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
> xTextTarget
;
111 PieLabelInfo
* pPrevious
;
113 ::com::sun::star::awt::Point aPreviousPosition
;
116 ::std::vector
< PieLabelInfo
> m_aLabelInfoList
;
118 double m_fMaxOffset
; /// cached max offset value (init'ed to NaN)
120 //.............................................................................
122 //.............................................................................
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */