From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- sc/source/ui/inc/RegressionDialog.hxx | 81 +++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 sc/source/ui/inc/RegressionDialog.hxx (limited to 'sc/source/ui/inc/RegressionDialog.hxx') diff --git a/sc/source/ui/inc/RegressionDialog.hxx b/sc/source/ui/inc/RegressionDialog.hxx new file mode 100644 index 0000000000..f3783c36c9 --- /dev/null +++ b/sc/source/ui/inc/RegressionDialog.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include "StatisticsTwoVariableDialog.hxx" +#include "TableFillingAndNavigationTools.hxx" + +class ScRegressionDialog : public ScStatisticsTwoVariableDialog +{ + bool mbUnivariate; + size_t mnNumIndependentVars; + size_t mnNumObservations; + bool mbUse3DAddresses; + bool mbCalcIntercept; + + std::unique_ptr mxWithLabelsCheckBox; + std::unique_ptr mxLinearRadioButton; + std::unique_ptr mxLogarithmicRadioButton; + std::unique_ptr mxErrorMessage; + std::unique_ptr mxConfidenceLevelField; + std::unique_ptr mxCalcResidualsCheckBox; + std::unique_ptr mxNoInterceptCheckBox; + +public: + ScRegressionDialog( + SfxBindings* pB, SfxChildWindow* pCW, + weld::Window* pParent, ScViewData& rViewData ); + + virtual ~ScRegressionDialog() override; + + virtual void Close() override; + +protected: + virtual TranslateId GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; + virtual bool InputRangesValid() override; + +private: + + using CellValueGetter = const OUString&(size_t, size_t); + using CellWriter = void(const OUString&, size_t, size_t); + + size_t GetRegressionTypeIndex() const; + ScRange GetDataRange(const ScRange& rRange); + OUString GetVariableNameFormula(bool bXVar, size_t nIndex, bool bWithLog); + OUString GetXVariableNameFormula(size_t nIndex, bool bWithLog); + OUString GetYVariableNameFormula(bool bWithLog); + + // Helper methods for writing different parts of regression results. + void WriteRawRegressionResults(AddressWalkerWriter& rOutput, + FormulaTemplate& rTemplate, + size_t nRegressionIndex); + void WriteRegressionStatistics(AddressWalkerWriter& rOutput, + FormulaTemplate& rTemplate); + void WriteRegressionANOVAResults(AddressWalkerWriter& rOutput, + FormulaTemplate& rTemplate); + void WriteRegressionEstimatesWithCI(AddressWalkerWriter& rOutput, + FormulaTemplate& rTemplate, + bool bTakeLogX); + void WritePredictionsWithResiduals(AddressWalkerWriter& rOutput, + FormulaTemplate& rTemplate, + size_t nRegressionIndex); + // Generic table writer + static void WriteTable(const std::function& rCellGetter, size_t nRowsInTable, + size_t nColsInTable, AddressWalkerWriter& rOutput, + const std::function& rFunc); + + DECL_LINK( CheckBoxHdl, weld::Toggleable&, void ); + DECL_LINK( NumericFieldHdl, weld::SpinButton&, void ); +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3