Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / tools / LinearRegressionCurveCalculator.cxx
blobee836555b1e4652b2fb181ab42ebeb13bc380bb7
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 .
20 #include <LinearRegressionCurveCalculator.hxx>
22 using namespace ::com::sun::star;
24 namespace chart
27 LinearRegressionCurveCalculator::LinearRegressionCurveCalculator()
30 LinearRegressionCurveCalculator::~LinearRegressionCurveCalculator()
33 void LinearRegressionCurveCalculator::setRegressionProperties(
34 sal_Int32 /*aDegree*/,
35 sal_Bool aForceIntercept,
36 double aInterceptValue,
37 sal_Int32 aPeriod,
38 sal_Int32 /*nMovingType*/)
40 PolynomialRegressionCurveCalculator::setRegressionProperties(
42 aForceIntercept,
43 aInterceptValue,
44 aPeriod,
45 0);
48 uno::Sequence< geometry::RealPoint2D > SAL_CALL LinearRegressionCurveCalculator::getCurveValues(
49 double min, double max, ::sal_Int32 nPointCount,
50 const uno::Reference< chart2::XScaling >& xScalingX,
51 const uno::Reference< chart2::XScaling >& xScalingY,
52 sal_Bool bMaySkipPointsInCalculation )
54 if( bMaySkipPointsInCalculation &&
55 isLinearScaling( xScalingX ) &&
56 isLinearScaling( xScalingY ))
58 // optimize result
59 uno::Sequence< geometry::RealPoint2D > aResult{ { min, getCurveValue( min ) },
60 { max, getCurveValue( max ) } };
62 return aResult;
64 return RegressionCurveCalculator::getCurveValues( min, max, nPointCount, xScalingX, xScalingY, bMaySkipPointsInCalculation );
67 } // namespace chart
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */