1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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
19 size_t mnNumIndependentVars
;
20 size_t mnNumObservations
;
21 bool mbUse3DAddresses
;
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
;
35 SfxBindings
* pB
, SfxChildWindow
* pCW
,
36 weld::Window
* pParent
, ScViewData
* pViewData
);
38 virtual ~ScRegressionDialog() override
;
40 virtual void Close() override
;
43 virtual const char* GetUndoNameId() override
;
44 virtual ScRange
ApplyOutput(ScDocShell
* pDocShell
) override
;
45 virtual bool InputRangesValid() override
;
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
,
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 );
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */