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/.
13 #include "StatisticsTwoVariableDialog.hxx"
14 #include "TableFillingAndNavigationTools.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::Label
> mxErrorMessage
;
28 std::unique_ptr
<weld::SpinButton
> mxConfidenceLevelField
;
29 std::unique_ptr
<weld::CheckButton
> mxCalcResidualsCheckBox
;
30 std::unique_ptr
<weld::CheckButton
> mxNoInterceptCheckBox
;
34 SfxBindings
* pB
, SfxChildWindow
* pCW
,
35 weld::Window
* pParent
, ScViewData
& rViewData
);
37 virtual ~ScRegressionDialog() override
;
39 virtual void Close() override
;
42 virtual TranslateId
GetUndoNameId() override
;
43 virtual ScRange
ApplyOutput(ScDocShell
* pDocShell
) override
;
44 virtual bool InputRangesValid() override
;
48 using CellValueGetter
= const OUString
&(size_t, size_t);
49 using CellWriter
= void(const OUString
&, size_t, size_t);
51 size_t GetRegressionTypeIndex() const;
52 ScRange
GetDataRange(const ScRange
& rRange
);
53 OUString
GetVariableNameFormula(bool bXVar
, size_t nIndex
, bool bWithLog
);
54 OUString
GetXVariableNameFormula(size_t nIndex
, bool bWithLog
);
55 OUString
GetYVariableNameFormula(bool bWithLog
);
57 // Helper methods for writing different parts of regression results.
58 void WriteRawRegressionResults(AddressWalkerWriter
& rOutput
,
59 FormulaTemplate
& rTemplate
,
60 size_t nRegressionIndex
);
61 void WriteRegressionStatistics(AddressWalkerWriter
& rOutput
,
62 FormulaTemplate
& rTemplate
);
63 void WriteRegressionANOVAResults(AddressWalkerWriter
& rOutput
,
64 FormulaTemplate
& rTemplate
);
65 void WriteRegressionEstimatesWithCI(AddressWalkerWriter
& rOutput
,
66 FormulaTemplate
& rTemplate
,
68 void WritePredictionsWithResiduals(AddressWalkerWriter
& rOutput
,
69 FormulaTemplate
& rTemplate
,
70 size_t nRegressionIndex
);
71 // Generic table writer
72 static void WriteTable(const std::function
<CellValueGetter
>& rCellGetter
, size_t nRowsInTable
,
73 size_t nColsInTable
, AddressWalkerWriter
& rOutput
,
74 const std::function
<CellWriter
>& rFunc
);
76 DECL_LINK( CheckBoxHdl
, weld::Toggleable
&, void );
77 DECL_LINK( NumericFieldHdl
, weld::SpinButton
&, void );
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */