Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / ui / inc / RegressionDialog.hxx
blobc5359520f0a88844dd92ccf5ebd0b53aece08700
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 */
11 #ifndef INCLUDED_SC_SOURCE_UI_INC_REGRESSIONDIALOG_HXX
12 #define INCLUDED_SC_SOURCE_UI_INC_REGRESSIONDIALOG_HXX
14 #include "StatisticsTwoVariableDialog.hxx"
16 class ScRegressionDialog : public ScStatisticsTwoVariableDialog
18 bool mbUnivariate;
19 size_t mnNumIndependentVars;
20 size_t mnNumObservations;
21 bool mbUse3DAddresses;
22 bool mbCalcIntercept;
24 std::unique_ptr<weld::CheckButton> mxWithLabelsCheckBox;
25 std::unique_ptr<weld::RadioButton> mxLinearRadioButton;
26 std::unique_ptr<weld::RadioButton> mxLogarithmicRadioButton;
27 std::unique_ptr<weld::RadioButton> mxPowerRadioButton;
28 std::unique_ptr<weld::Label> mxErrorMessage;
29 std::unique_ptr<weld::SpinButton> mxConfidenceLevelField;
30 std::unique_ptr<weld::CheckButton> mxCalcResidualsCheckBox;
31 std::unique_ptr<weld::CheckButton> mxNoInterceptCheckBox;
33 public:
34 ScRegressionDialog(
35 SfxBindings* pB, SfxChildWindow* pCW,
36 weld::Window* pParent, ScViewData* pViewData );
38 virtual ~ScRegressionDialog() override;
40 virtual void Close() override;
42 protected:
43 virtual const char* GetUndoNameId() override;
44 virtual ScRange ApplyOutput(ScDocShell* pDocShell) override;
45 virtual bool InputRangesValid() override;
47 private:
49 using CellValueGetter = const OUString&(size_t, size_t);
50 using CellWriter = void(const OUString&, size_t, size_t);
52 size_t GetRegressionTypeIndex() const;
53 ScRange GetDataRange(const ScRange& rRange);
54 OUString GetVariableNameFormula(bool bXVar, size_t nIndex, bool bWithLog);
55 OUString GetXVariableNameFormula(size_t nIndex, bool bWithLog);
56 OUString GetYVariableNameFormula(bool bWithLog);
58 // Helper methods for writing different parts of regression results.
59 void WriteRawRegressionResults(AddressWalkerWriter& rOutput,
60 FormulaTemplate& rTemplate,
61 size_t nRegressionIndex);
62 void WriteRegressionStatistics(AddressWalkerWriter& rOutput,
63 FormulaTemplate& rTemplate);
64 void WriteRegressionANOVAResults(AddressWalkerWriter& rOutput,
65 FormulaTemplate& rTemplate);
66 void WriteRegressionEstimatesWithCI(AddressWalkerWriter& rOutput,
67 FormulaTemplate& rTemplate,
68 bool bTakeLogX);
69 void WritePredictionsWithResiduals(AddressWalkerWriter& rOutput,
70 FormulaTemplate& rTemplate,
71 size_t nRegressionIndex);
72 // Generic table writer
73 static void WriteTable(const std::function<CellValueGetter>& rCellGetter, size_t nRowsInTable,
74 size_t nColsInTable, AddressWalkerWriter& rOutput,
75 const std::function<CellWriter>& rFunc);
77 DECL_LINK( CheckBoxHdl, weld::ToggleButton&, void );
78 DECL_LINK( NumericFieldHdl, weld::SpinButton&, void );
82 #endif
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */