Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / inc / RegressionCurveCalculator.hxx
blobebb3ad40f61601290086114421dd2a7dd4864062
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 <cppuhelper/implbase.hxx>
22 #include <rtl/ustrbuf.hxx>
24 #include <com/sun/star/chart2/XRegressionCurveCalculator.hpp>
26 namespace com::sun::star::util { class XNumberFormatsSupplier; }
27 namespace com::sun::star::util { class XNumberFormatter; }
29 namespace chart
32 class RegressionCurveCalculator : public
33 cppu::WeakImplHelper< css::chart2::XRegressionCurveCalculator >
35 public:
36 RegressionCurveCalculator();
37 virtual ~RegressionCurveCalculator() override;
39 static bool isLinearScaling(
40 const css::uno::Reference< css::chart2::XScaling >& xScaling );
42 static bool isLogarithmicScaling(
43 const css::uno::Reference< css::chart2::XScaling >& xScaling );
45 // ____ XRegressionCurveCalculator ____
46 virtual void SAL_CALL setRegressionProperties(
47 sal_Int32 aDegree,
48 sal_Bool aForceIntercept,
49 double aInterceptValue,
50 sal_Int32 aPeriod,
51 sal_Int32 nMovingType) override;
53 virtual void SAL_CALL recalculateRegression(
54 const css::uno::Sequence< double >& aXValues,
55 const css::uno::Sequence< double >& aYValues ) override = 0;
57 virtual double SAL_CALL getCurveValue( double x ) override = 0;
59 virtual css::uno::Sequence< css::geometry::RealPoint2D > SAL_CALL getCurveValues(
60 double min,
61 double max,
62 sal_Int32 nPointCount,
63 const css::uno::Reference< css::chart2::XScaling >& xScalingX,
64 const css::uno::Reference< css::chart2::XScaling >& xScalingY,
65 sal_Bool bMaySkipPointsInCalculation ) override;
67 virtual double SAL_CALL getCorrelationCoefficient() override;
69 virtual OUString SAL_CALL getRepresentation() override;
71 virtual OUString SAL_CALL getFormattedRepresentation(
72 const css::uno::Reference< css::util::XNumberFormatsSupplier >& xNumFmtSupplier,
73 sal_Int32 nNumberFormatKey, sal_Int32 nFormulaLength ) override;
75 virtual void SAL_CALL setXYNames(
76 const OUString& aXName, const OUString& aYName ) override;
78 protected:
79 virtual OUString ImplGetRepresentation(
80 const css::uno::Reference< css::util::XNumberFormatter >& xNumFormatter,
81 sal_Int32 nNumberFormatKey, sal_Int32* pFormulaLength = nullptr ) const = 0;
83 static OUString getFormattedString(
84 const css::uno::Reference< css::util::XNumberFormatter >& xNumFormatter,
85 sal_Int32 nNumberFormatKey,
86 double fNumber,
87 const sal_Int32* pStringLength );
89 static void addStringToEquation( OUStringBuffer& aStrEquation, sal_Int32& nLineLength, OUStringBuffer const & aAddString, const sal_Int32* pMaxLength );
91 double m_fCorrelationCoefficient;
93 sal_Int32 mDegree;
94 bool mForceIntercept;
95 double mInterceptValue;
96 sal_Int32 mPeriod;
97 OUString mXName, mYName;
98 sal_Int32 mnMovingType;
101 } // namespace chart
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */