tdf#120397 - odf export fix missing texts in text box control
[LibreOffice.git] / chart2 / source / view / main / SeriesPlotterContainer.hxx
blob38f3c8b909c8648c889afaa172822d0d843e29f3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <config_feature_desktop.h>
21 #include <VSeriesPlotter.hxx>
22 #include <BaseCoordinateSystem.hxx>
23 #include "AxisUsage.hxx"
25 namespace chart
27 /** This class is a container of `SeriesPlotter` objects (such as `PieChart`
28 * instances). It is used for initializing coordinate systems, axes and scales
29 * of all series plotters which belongs to the container.
31 class SeriesPlotterContainer
33 public:
34 explicit SeriesPlotterContainer(std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList);
35 ~SeriesPlotterContainer();
37 /** It is used to set coordinate systems (`m_rVCooSysList`), this method
38 * is invoked by `ChartView::createShapes2D` before of
39 * `ChartView::impl_createDiagramAndContent`.
40 * Coordinate systems are retrieved through the `XCoordinateSystemContainer`
41 * interface implemented by a diagram object which is provided by the
42 * `ChartModel` object passed to the method (`rChartModel.getFirstDiagram()`).
44 * It is used for creating series plotters and appending them
45 * to `m_aSeriesPlotterList`. The created series plotters are initialized
46 * through data (number formats supplier, color scheme, data series),
47 * extracted from the chart model or the diagram objects. An exception is
48 * the explicit category provider that is retrieved through the
49 * `VCoordinateSystem` object used by the series plotter.
51 * It sets the minimum-maximum supplier for a coordinate system:
52 * this supplier is the series plotter itself which utilizes the given
53 * coordinate system. In fact `VSeriesPlotter` has `MinimumMaximumSupplier`
54 * as one of its base classes.
55 * Hence, for instance, a `PieChart`, which is a series plotter, is
56 * a `MinimumMaximumSupplier`, too.
58 void initializeCooSysAndSeriesPlotter(ChartModel& rModel);
60 /** This method is invoked by `ChartView::impl_createDiagramAndContent`.
61 * It iterates on every axis of every coordinate systems, and if the axis
62 * is not yet present in `m_aAxisUsageList` it creates a new `AxisUsage`
63 * object and initialize its `aAutoScaling` member to the `ScaleData`
64 * object of the current axis.
66 void initAxisUsageList(const Date& rNullDate);
68 /**
69 * Perform automatic axis scaling and determine the amount and spacing of
70 * increments. It assumes that the caller has determined the size of the
71 * largest axis label text object prior to calling this method.
73 * The new axis scaling data will be stored in the VCoordinateSystem
74 * objects. The label alignment direction for each axis will also get
75 * determined during this process, and stored in VAxis.
77 * This method is invoked by `ChartView::impl_createDiagramAndContent`
78 * soon after `initAxisUsageList`.
79 * It initializes explicit scale and increment objects for all coordinate
80 * systems in `m_rVCooSysList`.
81 * This action is achieved by iterating on the `m_aAxisUsageList` container,
82 * and performing 3 steps:
83 * 1- call `VCoordinateSystem::prepareAutomaticAxisScaling` for setting
84 * scaling parameters of the `aAutoScaling` member (a `ScaleAutomatism`
85 * object) for the current `AxisUsage` instance
86 * (see `VCoordinateSystem::prepareAutomaticAxisScaling`);
87 * 2- calculate the explicit scale and increment objects
88 * (see ScaleAutomatism::calculateExplicitScaleAndIncrement);
89 * 3- set the explicit scale and increment objects for each coordinate
90 * system.
92 void doAutoScaling(ChartModel& rModel);
94 /**
95 * After auto-scaling is performed, call this method to set the explicit
96 * scaling and increment data to all relevant VAxis objects.
98 void updateScalesAndIncrementsOnAxes();
101 * After auto-scaling is performed, call this method to set the explicit
102 * scaling data to all the plotters.
104 void setScalesFromCooSysToPlotter();
106 void setNumberFormatsFromAxes();
107 css::drawing::Direction3D getPreferredAspectRatio();
109 std::vector<std::unique_ptr<VSeriesPlotter>>& getSeriesPlotterList()
111 return m_aSeriesPlotterList;
113 std::vector<std::unique_ptr<VCoordinateSystem>>& getCooSysList() { return m_rVCooSysList; }
114 std::vector<LegendEntryProvider*> getLegendEntryProviderList();
116 void AdaptScaleOfYAxisWithoutAttachedSeries(ChartModel& rModel);
118 bool isCategoryPositionShifted(const css::chart2::ScaleData& rSourceScale,
119 bool bHasComplexCategories);
121 static VCoordinateSystem*
122 getCooSysForPlotter(const std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList,
123 MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier);
124 static VCoordinateSystem*
125 addCooSysToList(std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList,
126 const rtl::Reference<BaseCoordinateSystem>& xCooSys, ChartModel& rChartModel);
127 static VCoordinateSystem*
128 findInCooSysList(const std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList,
129 const rtl::Reference<BaseCoordinateSystem>& xCooSys);
131 private:
132 /** A vector of series plotters.
134 std::vector<std::unique_ptr<VSeriesPlotter>> m_aSeriesPlotterList;
136 /** A vector of coordinate systems.
138 std::vector<std::unique_ptr<VCoordinateSystem>>& m_rVCooSysList;
140 /** A map whose key is a `XAxis` interface and the related value is
141 * an object of `AxisUsage` type.
143 std::map<rtl::Reference<Axis>, AxisUsage> m_aAxisUsageList;
146 * Max axis index of all dimensions. Currently this can be either 0 or 1
147 * since we only support primary and secondary axes per dimension. The
148 * value of 0 means all dimensions have only primary axis, while 1 means
149 * at least one dimension has a secondary axis.
151 sal_Int32 m_nMaxAxisIndex;
153 bool m_bChartTypeUsesShiftedCategoryPositionPerDefault;
154 bool m_bTableShiftPosition = false;
155 sal_Int32 m_nDefaultDateNumberFormat;
158 } //end chart2 namespace
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */