LibreOffice Module chart2 (master) 1
PieChart.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <memory>
23#include <VSeriesPlotter.hxx>
25#include <com/sun/star/awt/Point.hpp>
26
27namespace chart
28{
29class PiePositionHelper;
30
32{
33 struct ShapeParam;
34
35public:
36 PieChart() = delete;
37
39 , sal_Int32 nDimensionCount, bool bExcludingPositioning );
40 virtual ~PieChart() override;
41
44 virtual void createShapes() override;
45 virtual void rearrangeLabelToAvoidOverlapIfRequested( const css::awt::Size& rPageSize ) override;
46
47 virtual void setScales( std::vector< ExplicitScaleData >&& rScales, bool bSwapXAndYAxis ) override;
48 virtual void addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot ) override;
49
50 virtual css::drawing::Direction3D getPreferredDiagramAspectRatio() const override;
51 virtual bool shouldSnapRectToUsedArea() override;
52
53 //MinimumAndMaximumSupplier
54 virtual double getMinimumX() override;
55 virtual double getMaximumX() override;
56 virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) override;
57 virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) override;
58
59 virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex ) override;
60 virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ) override;
61 virtual bool isExpandWideValuesToZero( sal_Int32 nDimensionIndex ) override;
62 virtual bool isExpandNarrowValuesTowardZero( sal_Int32 nDimensionIndex ) override;
63 virtual bool isSeparateStackingForDifferentSigns( sal_Int32 nDimensionIndex ) override;
64
65private: //methods
69 const css::uno::Reference<css::beans::XPropertySet>& xObjectProperties,
70 const ShapeParam& rParam,
71 const sal_Int32 nPointCount,
72 const bool bConcentricExplosion);
73
86 const rtl::Reference<SvxShapeGroupAnyD>& xTextTarget,
87 VDataSeries& rSeries, sal_Int32 nPointIndex, ShapeParam& rParam );
88
101 double getMaxOffset();
102 bool detectLabelOverlapsAndMove(const css::awt::Size& rPageSize);//returns true when there might be more to do
104struct PieLabelInfo;
105 bool tryMoveLabels( PieLabelInfo const * pFirstBorder, PieLabelInfo const * pSecondBorder
106 , PieLabelInfo* pCenter, bool bSingleCenter, bool& rbAlternativeMoveDirection
107 , const css::awt::Size& rPageSize );
108
110 , PieLabelInfo const & rPieLabelInfo );
111
112private: //member
113 std::unique_ptr<PiePositionHelper>
117
119 {
120 PieLabelInfo();
121 bool moveAwayFrom( const PieLabelInfo* pFix, const css::awt::Size& rPageSize
122 , bool bMoveHalfWay, bool bMoveClockwise );
123
129 double fValue;
131 bool bMoved;
136 css::awt::Point aPreviousPosition;
137 };
138
139 std::vector< PieLabelInfo > m_aLabelInfoList;
140
142};
143} //namespace chart
144
145/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PieChart(const rtl::Reference< ::chart::ChartType > &xChartTypeModel, sal_Int32 nDimensionCount, bool bExcludingPositioning)
virtual bool isSeparateStackingForDifferentSigns(sal_Int32 nDimensionIndex) override
Definition: PieChart.cxx:666
virtual double getMinimumX() override
Definition: PieChart.cxx:578
bool detectLabelOverlapsAndMove(const css::awt::Size &rPageSize)
Definition: PieChart.cxx:1003
virtual void createShapes() override
This method creates all shapes needed for representing the pie chart.
Definition: PieChart.cxx:671
virtual bool shouldSnapRectToUsedArea() override
Definition: PieChart.cxx:244
std::vector< PieLabelInfo > m_aLabelInfoList
Definition: PieChart.hxx:139
rtl::Reference< SvxShape > createDataPoint(const rtl::Reference< SvxShapeGroupAnyD > &xTarget, const css::uno::Reference< css::beans::XPropertySet > &xObjectProperties, const ShapeParam &rParam, const sal_Int32 nPointCount, const bool bConcentricExplosion)
Definition: PieChart.cxx:249
bool performLabelBestFitInnerPlacement(ShapeParam &rShapeParam, PieLabelInfo const &rPieLabelInfo)
Handle the placement of the label in the best fit case: the routine try to place the label inside the...
Definition: PieChart.cxx:1411
virtual ~PieChart() override
Definition: PieChart.cxx:227
virtual bool isExpandBorderToIncrementRhythm(sal_Int32 nDimensionIndex) override
Definition: PieChart.cxx:646
void resetLabelPositionsToPreviousState()
Definition: PieChart.cxx:997
virtual bool isExpandWideValuesToZero(sal_Int32 nDimensionIndex) override
Definition: PieChart.cxx:656
void createTextLabelShape(const rtl::Reference< SvxShapeGroupAnyD > &xTextTarget, VDataSeries &rSeries, sal_Int32 nPointIndex, ShapeParam &rParam)
This method creates a text shape for a label of a data point.
Definition: PieChart.cxx:316
virtual double getMaximumYInRange(double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex) override
Definition: PieChart.cxx:641
std::unique_ptr< PiePositionHelper > m_pPosHelper
Definition: PieChart.hxx:114
double m_fMaxOffset
Definition: PieChart.hxx:141
virtual void addSeries(std::unique_ptr< VDataSeries > pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot) override
A new series can be positioned relative to other series in a chart.
Definition: PieChart.cxx:573
bool tryMoveLabels(PieLabelInfo const *pFirstBorder, PieLabelInfo const *pSecondBorder, PieLabelInfo *pCenter, bool bSingleCenter, bool &rbAlternativeMoveDirection, const css::awt::Size &rPageSize)
Try to remove all overlaps that occur in the list of labels going from pFirstBorder to pSecondBorder
Definition: PieChart.cxx:1152
virtual double getMaximumX() override
Definition: PieChart.cxx:629
virtual double getMinimumYInRange(double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex) override
Definition: PieChart.cxx:636
virtual bool isExpandNarrowValuesTowardZero(sal_Int32 nDimensionIndex) override
Definition: PieChart.cxx:661
virtual css::drawing::Direction3D getPreferredDiagramAspectRatio() const override
a value <= 0 for a directions means that this direction can be stretched arbitrary
Definition: PieChart.cxx:237
virtual void rearrangeLabelToAvoidOverlapIfRequested(const css::awt::Size &rPageSize) override
Definition: PieChart.cxx:1248
virtual bool isExpandIfValuesCloseToBorder(sal_Int32 nDimensionIndex) override
Definition: PieChart.cxx:651
double getMaxOffset()
This method sets m_fMaxOffset to the maximum Offset property and returns it.
Definition: PieChart.cxx:582
virtual void setScales(std::vector< ExplicitScaleData > &&rScales, bool bSwapXAndYAxis) override
Definition: PieChart.cxx:231
bool m_bSizeExcludesLabelsAndExplodedSegments
Definition: PieChart.hxx:116
PieChart()=delete
css::awt::Point aPreviousPosition
Definition: PieChart.hxx:136
::basegfx::B2IVector aFirstPosition
Definition: PieChart.hxx:126
::basegfx::B2IVector aOuterPosition
Definition: PieChart.hxx:127
rtl::Reference< SvxShapeGroupAnyD > xLabelGroupShape
Definition: PieChart.hxx:125
bool moveAwayFrom(const PieLabelInfo *pFix, const css::awt::Size &rPageSize, bool bMoveHalfWay, bool bMoveClockwise)
In case this label and the passed label overlap the routine moves this label in order to fix the issu...
Definition: PieChart.cxx:928
rtl::Reference< SvxShapeGroupAnyD > xTextTarget
Definition: PieChart.hxx:133
rtl::Reference< SvxShapeText > xTextShape
Definition: PieChart.hxx:124
::basegfx::B2IVector aOrigin
Definition: PieChart.hxx:128