Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / inc / RegressionCurveHelper.hxx
blobf9d919506460106cb1e71797c9ffeb971fddb3c1
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 .
19 #pragma once
21 #include <svx/chrtitem.hxx>
22 #include "charttoolsdllapi.hxx"
23 #include <rtl/ref.hxx>
25 #include <vector>
27 namespace com::sun::star::beans { class XPropertySet; }
28 namespace com::sun::star::chart2 { class XDataSeries; }
29 namespace com::sun::star::chart2 { class XDiagram; }
30 namespace com::sun::star::chart2 { class XRegressionCurve; }
31 namespace com::sun::star::chart2 { class XRegressionCurveCalculator; }
32 namespace com::sun::star::chart2 { class XRegressionCurveContainer; }
33 namespace com::sun::star::chart2::data { class XDataSource; }
34 namespace com::sun::star::frame { class XModel; }
35 namespace chart { class ChartModel; }
36 namespace chart { class DataSeries; }
37 namespace chart { class RegressionCurveModel; }
38 namespace chart { class RegressionCurveCalculator; }
40 namespace chart::RegressionCurveHelper
42 /// returns a model mean-value line
43 rtl::Reference<::chart::RegressionCurveModel> createMeanValueLine();
45 /// returns a model regression curve
46 rtl::Reference<::chart::RegressionCurveModel>
47 createRegressionCurveByServiceName( std::u16string_view aServiceName );
49 OOO_DLLPUBLIC_CHARTTOOLS bool hasMeanValueLine(
50 const css::uno::Reference<css::chart2::XRegressionCurveContainer> & xRegCnt );
51 OOO_DLLPUBLIC_CHARTTOOLS bool hasMeanValueLine(
52 const rtl::Reference<::chart::DataSeries> & xRegCnt );
54 OOO_DLLPUBLIC_CHARTTOOLS bool isMeanValueLine(
55 const css::uno::Reference<css::chart2::XRegressionCurve> & xRegCurve );
56 OOO_DLLPUBLIC_CHARTTOOLS bool isMeanValueLine(
57 const rtl::Reference<::chart::RegressionCurveModel> & xRegCurve );
59 OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel>
60 getMeanValueLine(
61 const css::uno::Reference<css::chart2::XRegressionCurveContainer> & xRegCnt );
62 OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel>
63 getMeanValueLine(
64 const rtl::Reference<::chart::DataSeries> & xRegCnt );
66 /** creates a mean-value line and adds it to the container.
68 @param xSeriesProp
69 If set, this property-set will be used to apply a line color
71 OOO_DLLPUBLIC_CHARTTOOLS void addMeanValueLine(
72 css::uno::Reference<css::chart2::XRegressionCurveContainer> const & xRegCnt,
73 const css::uno::Reference<css::beans::XPropertySet>& xSeriesProp );
74 OOO_DLLPUBLIC_CHARTTOOLS void addMeanValueLine(
75 rtl::Reference<::chart::DataSeries> const & xRegCnt,
76 const css::uno::Reference<css::beans::XPropertySet>& xSeriesProp );
78 OOO_DLLPUBLIC_CHARTTOOLS void removeMeanValueLine(
79 css::uno::Reference<css::chart2::XRegressionCurveContainer> const & xRegCnt );
80 OOO_DLLPUBLIC_CHARTTOOLS void removeMeanValueLine(
81 rtl::Reference<::chart::DataSeries> const & xRegCnt );
83 /** Returns the first regression curve found that is not of type
84 mean-value line
86 OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel>
87 getFirstCurveNotMeanValueLine(
88 const css::uno::Reference<css::chart2::XRegressionCurveContainer>& xCurveContainer );
89 OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel>
90 getFirstCurveNotMeanValueLine(
91 const rtl::Reference<::chart::DataSeries>& xCurveContainer );
93 /** Returns the regression curve found at the index provided.
95 OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel>
96 getRegressionCurveAtIndex(
97 const rtl::Reference<::chart::DataSeries>& xCurveContainer,
98 sal_Int32 aIndex);
100 /** Returns the type of the first regression curve found that is not of type
101 mean-value line
103 OOO_DLLPUBLIC_CHARTTOOLS SvxChartRegress getFirstRegressTypeNotMeanValueLine(
104 const css::uno::Reference<css::chart2::XRegressionCurveContainer>& xCurveContainer );
106 OOO_DLLPUBLIC_CHARTTOOLS SvxChartRegress getRegressionType(
107 const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve );
109 /** @param xPropertySource is taken as source to copy all properties from if
110 not null
111 @param xEquationProperties is set at the new regression curve as
112 equation properties if not null
114 OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel>
115 addRegressionCurve(
116 SvxChartRegress eType,
117 css::uno::Reference<css::chart2::XRegressionCurveContainer> const & xCurveContainer,
118 const css::uno::Reference<css::beans::XPropertySet >& xPropertySource =
119 css::uno::Reference<css::beans::XPropertySet>(),
120 const css::uno::Reference<css::beans::XPropertySet>& xEquationProperties =
121 css::uno::Reference<css::beans::XPropertySet>() );
122 OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel>
123 addRegressionCurve(
124 SvxChartRegress eType,
125 rtl::Reference<::chart::DataSeries> const & xCurveContainer,
126 const css::uno::Reference<css::beans::XPropertySet >& xPropertySource =
127 css::uno::Reference<css::beans::XPropertySet>(),
128 const css::uno::Reference<css::beans::XPropertySet>& xEquationProperties =
129 css::uno::Reference<css::beans::XPropertySet>() );
131 OOO_DLLPUBLIC_CHARTTOOLS bool removeAllExceptMeanValueLine(
132 rtl::Reference<::chart::DataSeries> const & xCurveContainer );
134 OOO_DLLPUBLIC_CHARTTOOLS void removeEquations(
135 rtl::Reference<::chart::DataSeries> const & xCurveContainer );
137 OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel>
138 changeRegressionCurveType(
139 SvxChartRegress eType,
140 css::uno::Reference<css::chart2::XRegressionCurveContainer> const & xRegressionCurveContainer,
141 css::uno::Reference<css::chart2::XRegressionCurve> const & xRegressionCurve );
143 /// returns a calculator object for regression curves (used by the view)
144 OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveCalculator>
145 createRegressionCurveCalculatorByServiceName( std::u16string_view aServiceName );
147 /** recalculates the regression parameters according to the data given in
148 the data source.
150 A sequence having the role "values-x" will be used as x-values for the
151 calculation if found. Otherwise a sequence (1, 2, 3, ...) of category
152 indexes will be used for the recalculateRegression() method of the
153 regression curve.
155 The first sequence having the role "values-y" will be used as y-values
156 for the recalculateRegression() method of the regression curve.
158 @param bUseXValuesIfAvailable
159 If false, the sequence (1, 2, 3, ...) will always be used, even if
160 there is a data-sequence with role "values-x"
162 void initializeCurveCalculator(
163 const css::uno::Reference<css::chart2::XRegressionCurveCalculator>& xOutCurveCalculator,
164 const css::uno::Reference<css::chart2::data::XDataSource>& xSource,
165 bool bUseXValuesIfAvailable );
167 /** Same method as above, but uses the given XModel to determine the
168 parameter bUseXValuesIfAvailable in the above function. It is also
169 necessary that the data::XDataSource is an XDataSeries, thus this parameter
170 also changed.
172 OOO_DLLPUBLIC_CHARTTOOLS void initializeCurveCalculator(
173 const css::uno::Reference<css::chart2::XRegressionCurveCalculator>& xOutCurveCalculator,
174 const rtl::Reference<::chart::DataSeries>& xSeries,
175 const rtl::Reference<::chart::ChartModel>& xModel );
177 OOO_DLLPUBLIC_CHARTTOOLS OUString getUINameForRegressionCurve(
178 const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve );
180 OOO_DLLPUBLIC_CHARTTOOLS OUString getRegressionCurveName(
181 const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve );
183 OOO_DLLPUBLIC_CHARTTOOLS OUString getRegressionCurveGenericName(
184 const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve );
186 OOO_DLLPUBLIC_CHARTTOOLS OUString getRegressionCurveSpecificName(
187 const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve );
189 OOO_DLLPUBLIC_CHARTTOOLS void resetEquationPosition(
190 const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve );
192 /// @return the index of the given curve in the given container. -1 if not contained
193 OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getRegressionCurveIndex(
194 const rtl::Reference<::chart::DataSeries>& xContainer,
195 const rtl::Reference<::chart::RegressionCurveModel>& xCurve );
197 OOO_DLLPUBLIC_CHARTTOOLS bool hasEquation(const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve );
198 OOO_DLLPUBLIC_CHARTTOOLS bool MayHaveCorrelationCoefficient(const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve );
200 } // namespace chart
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */