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