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 .
19 #ifndef INCLUDED_CHART2_SOURCE_INC_REGRESSIONCURVEHELPER_HXX
20 #define INCLUDED_CHART2_SOURCE_INC_REGRESSIONCURVEHELPER_HXX
22 #include <com/sun/star/chart2/XRegressionCurve.hpp>
23 #include <com/sun/star/chart2/XRegressionCurveCalculator.hpp>
24 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
25 #include <com/sun/star/chart2/data/XDataSource.hpp>
26 #include <com/sun/star/chart2/XDataSeries.hpp>
27 #include <com/sun/star/chart2/XDiagram.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <com/sun/star/frame/XModel.hpp>
30 #include <svx/chrtitem.hxx>
31 #include "charttoolsdllapi.hxx"
38 namespace RegressionCurveHelper
40 /// returns a model mean-value line
41 css::uno::Reference
<css::chart2::XRegressionCurve
>
42 createMeanValueLine(const css::uno::Reference
<css::uno::XComponentContext
> & xContext
);
44 /// returns a model regression curve
45 css::uno::Reference
<css::chart2::XRegressionCurve
>
46 createRegressionCurveByServiceName(
47 const css::uno::Reference
<css::uno::XComponentContext
> & xContext
,
48 const OUString
& aServiceName
);
50 OOO_DLLPUBLIC_CHARTTOOLS
bool hasMeanValueLine(
51 const css::uno::Reference
<css::chart2::XRegressionCurveContainer
> & xRegCnt
);
53 OOO_DLLPUBLIC_CHARTTOOLS
bool isMeanValueLine(
54 const css::uno::Reference
<css::chart2::XRegressionCurve
> & xRegCurve
);
56 OOO_DLLPUBLIC_CHARTTOOLS
css::uno::Reference
<css::chart2::XRegressionCurve
>
58 const css::uno::Reference
<css::chart2::XRegressionCurveContainer
> & xRegCnt
);
60 /** creates a mean-value line and adds it to the container.
63 If set, this property-set will be used to apply a line color
65 OOO_DLLPUBLIC_CHARTTOOLS
void addMeanValueLine(
66 css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xRegCnt
,
67 const css::uno::Reference
<css::uno::XComponentContext
>& xContext
,
68 const css::uno::Reference
<css::beans::XPropertySet
>& xSeriesProp
);
70 OOO_DLLPUBLIC_CHARTTOOLS
void removeMeanValueLine(
71 css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xRegCnt
);
73 /** Returns the first regression curve found that is not of type
76 OOO_DLLPUBLIC_CHARTTOOLS
css::uno::Reference
<com::sun::star::chart2::XRegressionCurve
>
77 getFirstCurveNotMeanValueLine(
78 const css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xCurveContainer
);
80 /** Returns the regression curve found at the index provided.
82 OOO_DLLPUBLIC_CHARTTOOLS
css::uno::Reference
<css::chart2::XRegressionCurve
>
83 getRegressionCurveAtIndex(
84 const css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xCurveContainer
,
87 /** Returns the type of the first regression curve found that is not of type
90 OOO_DLLPUBLIC_CHARTTOOLS SvxChartRegress
getFirstRegressTypeNotMeanValueLine(
91 const css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xCurveContainer
);
93 OOO_DLLPUBLIC_CHARTTOOLS SvxChartRegress
getRegressionType(
94 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
96 /** @param xPropertySource is taken as source to copy all properties from if
98 @param xEquationProperties is set at the new regression curve as
99 equation properties if not null
101 OOO_DLLPUBLIC_CHARTTOOLS
css::uno::Reference
<css::chart2::XRegressionCurve
>
103 SvxChartRegress eType
,
104 css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xCurveContainer
,
105 const css::uno::Reference
<css::uno::XComponentContext
>& xContext
,
106 const css::uno::Reference
<css::beans::XPropertySet
>& xPropertySource
=
107 css::uno::Reference
<css::beans::XPropertySet
>(),
108 const css::uno::Reference
<css::beans::XPropertySet
>& xEquationProperties
=
109 css::uno::Reference
<css::beans::XPropertySet
>() );
111 OOO_DLLPUBLIC_CHARTTOOLS
bool removeAllExceptMeanValueLine(
112 css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xCurveContainer
);
114 OOO_DLLPUBLIC_CHARTTOOLS
void removeEquations(
115 css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xCurveContainer
);
117 OOO_DLLPUBLIC_CHARTTOOLS
css::uno::Reference
<css::chart2::XRegressionCurve
>
118 changeRegressionCurveType(
119 SvxChartRegress eType
,
120 css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xRegressionCurveContainer
,
121 css::uno::Reference
<css::chart2::XRegressionCurve
>& xRegressionCurve
,
122 const css::uno::Reference
<css::uno::XComponentContext
>& xContext
);
124 /// returns a calculator object for regression curves (used by the view)
125 OOO_DLLPUBLIC_CHARTTOOLS
css::uno::Reference
<css::chart2::XRegressionCurveCalculator
>
126 createRegressionCurveCalculatorByServiceName( const OUString
& aServiceName
);
128 /** recalculates the regression parameters according to the data given in
131 A sequence having the role "values-x" will be used as x-values for the
132 calculation if found. Otherwise a sequence (1, 2, 3, ...) of category
133 indexes will be used for the recalculateRegression() method of the
136 The first sequence having the role "values-y" will be used as y-values
137 for the recalculateRegression() method of the regression curve.
139 @param bUseXValuesIfAvailable
140 If false, the sequence (1, 2, 3, ...) will always be used, even if
141 there is a data-sequence with role "values-x"
143 void initializeCurveCalculator(
144 const css::uno::Reference
<css::chart2::XRegressionCurveCalculator
>& xOutCurveCalculator
,
145 const css::uno::Reference
<css::chart2::data::XDataSource
>& xSource
,
146 bool bUseXValuesIfAvailable
= true );
148 /** Same method as above, but uses the given XModel to determine the
149 parameter bUseXValuesIfAvailable in the above function. It is also
150 necessary that the data::XDataSource is an XDataSeries, thus this parameter
153 OOO_DLLPUBLIC_CHARTTOOLS
void initializeCurveCalculator(
154 const css::uno::Reference
<css::chart2::XRegressionCurveCalculator
>& xOutCurveCalculator
,
155 const css::uno::Reference
<css::chart2::XDataSeries
>& xSeries
,
156 const css::uno::Reference
<css::frame::XModel
>& xModel
);
158 OOO_DLLPUBLIC_CHARTTOOLS OUString
getUINameForRegressionCurve(
159 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
161 OOO_DLLPUBLIC_CHARTTOOLS OUString
getRegressionCurveName(
162 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
164 OOO_DLLPUBLIC_CHARTTOOLS OUString
getRegressionCurveGenericName(
165 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
167 OOO_DLLPUBLIC_CHARTTOOLS OUString
getRegressionCurveSpecificName(
168 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
170 OOO_DLLPUBLIC_CHARTTOOLS
std::vector
<css::uno::Reference
<css::chart2::XRegressionCurve
> >
171 getAllRegressionCurvesNotMeanValueLine(
172 const css::uno::Reference
<css::chart2::XDiagram
>& xDiagram
);
174 OOO_DLLPUBLIC_CHARTTOOLS
void resetEquationPosition(
175 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
177 /// @return the index of the given curve in the given container. -1 if not contained
178 OOO_DLLPUBLIC_CHARTTOOLS sal_Int32
getRegressionCurveIndex(
179 const css::uno::Reference
<css::chart2::XRegressionCurveContainer
>& xContainer
,
180 const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
182 OOO_DLLPUBLIC_CHARTTOOLS
bool hasEquation(const css::uno::Reference
<css::chart2::XRegressionCurve
>& xCurve
);
187 #endif // INCLUDED_CHART2_SOURCE_INC_REGRESSIONCURVEHELPER_HXX
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */