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 .
21 #include <config_options.h>
22 #include <svx/chrtitem.hxx>
23 #include "charttoolsdllapi.hxx"
24 #include <rtl/ref.hxx>
28 namespace com::sun::star::beans
{ class XPropertySet
; }
29 namespace com::sun::star::chart2
{ class XDataSeries
; }
30 namespace com::sun::star::chart2
{ class XDiagram
; }
31 namespace com::sun::star::chart2
{ class XRegressionCurve
; }
32 namespace com::sun::star::chart2
{ class XRegressionCurveCalculator
; }
33 namespace com::sun::star::chart2
{ class XRegressionCurveContainer
; }
34 namespace com::sun::star::chart2::data
{ class XDataSource
; }
35 namespace com::sun::star::frame
{ class XModel
; }
36 namespace chart
{ class ChartModel
; }
37 namespace chart
{ class DataSeries
; }
38 namespace chart
{ class RegressionCurveModel
; }
39 namespace chart
{ class RegressionCurveCalculator
; }
41 namespace chart::RegressionCurveHelper
43 /// returns a model mean-value line
44 rtl::Reference
<::chart::RegressionCurveModel
> createMeanValueLine();
46 /// returns a model regression curve
47 rtl::Reference
<::chart::RegressionCurveModel
>
48 createRegressionCurveByServiceName( std::u16string_view aServiceName
);
50 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) bool hasMeanValueLine(
51 const css::uno::Reference
<css::chart2::XRegressionCurveContainer
> & xRegCnt
);
52 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) bool hasMeanValueLine(
53 const rtl::Reference
<::chart::DataSeries
> & xRegCnt
);
55 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) bool isMeanValueLine(
56 const css::uno::Reference
<css::chart2::XRegressionCurve
> & xRegCurve
);
57 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) bool isMeanValueLine(
58 const rtl::Reference
<::chart::RegressionCurveModel
> & xRegCurve
);
60 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) rtl::Reference
<::chart::RegressionCurveModel
>
62 const css::uno::Reference
<css::chart2::XRegressionCurveContainer
> & xRegCnt
);
63 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) rtl::Reference
<::chart::RegressionCurveModel
>
65 const rtl::Reference
<::chart::DataSeries
> & xRegCnt
);
67 /** creates a mean-value line and adds it to the container.
70 If set, this property-set will be used to apply a line color
72 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) void addMeanValueLine(
73 css::uno::Reference
<css::chart2::XRegressionCurveContainer
> const & xRegCnt
,
74 const css::uno::Reference
<css::beans::XPropertySet
>& xSeriesProp
);
75 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) void addMeanValueLine(
76 rtl::Reference
<::chart::DataSeries
> const & xRegCnt
,
77 const css::uno::Reference
<css::beans::XPropertySet
>& xSeriesProp
);
79 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) void removeMeanValueLine(
80 css::uno::Reference
<css::chart2::XRegressionCurveContainer
> const & xRegCnt
);
81 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) void removeMeanValueLine(
82 rtl::Reference
<::chart::DataSeries
> const & xRegCnt
);
84 /** Returns the first regression curve found that is not of type
87 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) rtl::Reference
<::chart::RegressionCurveModel
>
88 getFirstCurveNotMeanValueLine(
89 const css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xCurveContainer
);
90 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) rtl::Reference
<::chart::RegressionCurveModel
>
91 getFirstCurveNotMeanValueLine(
92 const rtl::Reference
<::chart::DataSeries
>& xCurveContainer
);
94 /** Returns the regression curve found at the index provided.
96 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) rtl::Reference
<::chart::RegressionCurveModel
>
97 getRegressionCurveAtIndex(
98 const rtl::Reference
<::chart::DataSeries
>& xCurveContainer
,
101 /** Returns the type of the first regression curve found that is not of type
104 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) SvxChartRegress
getFirstRegressTypeNotMeanValueLine(
105 const css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xCurveContainer
);
107 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) SvxChartRegress
getRegressionType(
108 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
110 /** @param xPropertySource is taken as source to copy all properties from if
112 @param xEquationProperties is set at the new regression curve as
113 equation properties if not null
115 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) rtl::Reference
<::chart::RegressionCurveModel
>
117 SvxChartRegress eType
,
118 css::uno::Reference
<css::chart2::XRegressionCurveContainer
> const & xCurveContainer
,
119 const css::uno::Reference
<css::beans::XPropertySet
>& xPropertySource
=
120 css::uno::Reference
<css::beans::XPropertySet
>(),
121 const css::uno::Reference
<css::beans::XPropertySet
>& xEquationProperties
=
122 css::uno::Reference
<css::beans::XPropertySet
>() );
123 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) rtl::Reference
<::chart::RegressionCurveModel
>
125 SvxChartRegress eType
,
126 rtl::Reference
<::chart::DataSeries
> const & xCurveContainer
,
127 const css::uno::Reference
<css::beans::XPropertySet
>& xPropertySource
=
128 css::uno::Reference
<css::beans::XPropertySet
>(),
129 const css::uno::Reference
<css::beans::XPropertySet
>& xEquationProperties
=
130 css::uno::Reference
<css::beans::XPropertySet
>() );
132 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) bool removeAllExceptMeanValueLine(
133 rtl::Reference
<::chart::DataSeries
> const & xCurveContainer
);
135 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) void removeEquations(
136 rtl::Reference
<::chart::DataSeries
> const & xCurveContainer
);
138 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) rtl::Reference
<::chart::RegressionCurveModel
>
139 changeRegressionCurveType(
140 SvxChartRegress eType
,
141 css::uno::Reference
<css::chart2::XRegressionCurveContainer
> const & xRegressionCurveContainer
,
142 css::uno::Reference
<css::chart2::XRegressionCurve
> const & xRegressionCurve
);
144 /// returns a calculator object for regression curves (used by the view)
145 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) rtl::Reference
<::chart::RegressionCurveCalculator
>
146 createRegressionCurveCalculatorByServiceName( std::u16string_view aServiceName
);
148 /** recalculates the regression parameters according to the data given in
151 A sequence having the role "values-x" will be used as x-values for the
152 calculation if found. Otherwise a sequence (1, 2, 3, ...) of category
153 indexes will be used for the recalculateRegression() method of the
156 The first sequence having the role "values-y" will be used as y-values
157 for the recalculateRegression() method of the regression curve.
159 @param bUseXValuesIfAvailable
160 If false, the sequence (1, 2, 3, ...) will always be used, even if
161 there is a data-sequence with role "values-x"
163 void initializeCurveCalculator(
164 const css::uno::Reference
<css::chart2::XRegressionCurveCalculator
>& xOutCurveCalculator
,
165 const css::uno::Reference
<css::chart2::data::XDataSource
>& xSource
,
166 bool bUseXValuesIfAvailable
);
168 /** Same method as above, but uses the given XModel to determine the
169 parameter bUseXValuesIfAvailable in the above function. It is also
170 necessary that the data::XDataSource is an XDataSeries, thus this parameter
173 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) void initializeCurveCalculator(
174 const css::uno::Reference
<css::chart2::XRegressionCurveCalculator
>& xOutCurveCalculator
,
175 const rtl::Reference
<::chart::DataSeries
>& xSeries
,
176 const rtl::Reference
<::chart::ChartModel
>& xModel
);
178 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) OUString
getUINameForRegressionCurve(
179 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
181 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) OUString
getRegressionCurveName(
182 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
184 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) OUString
getRegressionCurveGenericName(
185 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
187 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) OUString
getRegressionCurveSpecificName(
188 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
190 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) void resetEquationPosition(
191 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
193 /// @return the index of the given curve in the given container. -1 if not contained
194 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) sal_Int32
getRegressionCurveIndex(
195 const rtl::Reference
<::chart::DataSeries
>& xContainer
,
196 const rtl::Reference
<::chart::RegressionCurveModel
>& xCurve
);
198 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) bool hasEquation(const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
199 UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS
) bool MayHaveCorrelationCoefficient(const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */