fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / StatisticsDialogs / FTestDialog.cxx
blobe18deb527a0253195db51bcb93407da79ed94214
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 #include <sfx2/dispatch.hxx>
12 #include <svl/zforlist.hxx>
13 #include <svl/undo.hxx>
14 #include <boost/random.hpp>
15 #include <boost/scoped_ptr.hpp>
17 #include "formulacell.hxx"
18 #include "rangelst.hxx"
19 #include "scitems.hxx"
20 #include "docsh.hxx"
21 #include "document.hxx"
22 #include "uiitems.hxx"
23 #include "reffact.hxx"
24 #include "strload.hxx"
25 #include "docfunc.hxx"
26 #include "StatisticsDialogs.hrc"
27 #include "TableFillingAndNavigationTools.hxx"
29 #include "FTestDialog.hxx"
31 ScFTestDialog::ScFTestDialog(
32 SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
33 vcl::Window* pParent, ScViewData* pViewData ) :
34 ScStatisticsTwoVariableDialog(
35 pSfxBindings, pChildWindow, pParent, pViewData,
36 "TTestDialog", "modules/scalc/ui/ttestdialog.ui" )
38 SetText(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST));
41 ScFTestDialog::~ScFTestDialog()
44 bool ScFTestDialog::Close()
46 return DoClose( ScFTestDialogWrapper::GetChildWindowId() );
49 sal_Int16 ScFTestDialog::GetUndoNameId()
51 return STR_FTEST_UNDO_NAME;
54 ScRange ScFTestDialog::ApplyOutput(ScDocShell* pDocShell)
56 AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument,
57 formula::FormulaGrammar::mergeToGrammar(formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
58 FormulaTemplate aTemplate(mDocument);
60 boost::scoped_ptr<DataRangeIterator> pVariable1Iterator;
61 if (mGroupedBy == BY_COLUMN)
62 pVariable1Iterator.reset(new DataRangeByColumnIterator(mVariable1Range));
63 else
64 pVariable1Iterator.reset(new DataRangeByRowIterator(mVariable1Range));
66 boost::scoped_ptr<DataRangeIterator> pVariable2Iterator;
67 if (mGroupedBy == BY_COLUMN)
68 pVariable2Iterator.reset(new DataRangeByColumnIterator(mVariable2Range));
69 else
70 pVariable2Iterator.reset(new DataRangeByRowIterator(mVariable2Range));
72 aTemplate.autoReplaceRange("%VARIABLE1_RANGE%", pVariable1Iterator->get());
73 aTemplate.autoReplaceRange("%VARIABLE2_RANGE%", pVariable2Iterator->get());
75 aOutput.writeBoldString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_UNDO_NAME));
76 aOutput.newLine();
78 // Alpha
79 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_LABEL_ALPHA));
80 aOutput.nextColumn();
81 aOutput.writeValue(0.05);
82 aTemplate.autoReplaceAddress("%ALPHA%", aOutput.current());
83 aOutput.newLine();
85 aOutput.nextColumn();
86 aOutput.writeBoldString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_VARIABLE_1_LABEL));
87 aOutput.nextColumn();
88 aOutput.writeBoldString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_VARIABLE_2_LABEL));
89 aOutput.newLine();
91 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STRID_CALC_MEAN));
92 aOutput.nextColumn();
93 aTemplate.setTemplate("=AVERAGE(%VARIABLE1_RANGE%)");
94 aOutput.writeFormula(aTemplate.getTemplate());
95 aOutput.nextColumn();
96 aTemplate.setTemplate("=AVERAGE(%VARIABLE2_RANGE%)");
97 aOutput.writeFormula(aTemplate.getTemplate());
98 aOutput.newLine();
100 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STRID_CALC_VARIANCE));
101 aOutput.nextColumn();
102 aTemplate.setTemplate("=VAR(%VARIABLE1_RANGE%)");
103 aOutput.writeFormula(aTemplate.getTemplate());
104 aTemplate.autoReplaceAddress("%VARIABLE1_VARIANCE%", aOutput.current());
105 aOutput.nextColumn();
106 aTemplate.setTemplate("=VAR(%VARIABLE2_RANGE%)");
107 aOutput.writeFormula(aTemplate.getTemplate());
108 aTemplate.autoReplaceAddress("%VARIABLE2_VARIANCE%", aOutput.current());
109 aOutput.newLine();
111 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_OBSERVATIONS_LABEL));
112 aOutput.nextColumn();
113 aTemplate.setTemplate("=COUNT(%VARIABLE1_RANGE%)");
114 aOutput.writeFormula(aTemplate.getTemplate());
115 aTemplate.autoReplaceAddress("%VARIABLE1_OBSERVATIONS%", aOutput.current());
116 aOutput.nextColumn();
117 aTemplate.setTemplate("=COUNT(%VARIABLE2_RANGE%)");
118 aOutput.writeFormula(aTemplate.getTemplate());
119 aTemplate.autoReplaceAddress("%VARIABLE2_OBSERVATIONS%", aOutput.current());
120 aOutput.newLine();
122 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_ANOVA_LABEL_DF));
123 aOutput.nextColumn();
124 aTemplate.setTemplate("=%VARIABLE1_OBSERVATIONS% - 1");
125 aOutput.writeFormula(aTemplate.getTemplate());
126 aTemplate.autoReplaceAddress("%VARIABLE1_DEGREE_OF_FREEDOM%", aOutput.current());
127 aOutput.nextColumn();
128 aTemplate.setTemplate("=%VARIABLE2_OBSERVATIONS% - 1");
129 aOutput.writeFormula(aTemplate.getTemplate());
130 aTemplate.autoReplaceAddress("%VARIABLE2_DEGREE_OF_FREEDOM%", aOutput.current());
131 aOutput.newLine();
133 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_ANOVA_LABEL_F));
134 aOutput.nextColumn();
135 aTemplate.setTemplate("=%VARIABLE1_VARIANCE% / %VARIABLE2_VARIANCE%");
136 aOutput.writeFormula(aTemplate.getTemplate());
137 aTemplate.autoReplaceAddress("%F_VALUE%", aOutput.current());
138 aOutput.newLine();
140 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_P_RIGHT_TAIL));
141 aOutput.nextColumn();
142 aTemplate.setTemplate("=FDIST(%F_VALUE%; %VARIABLE1_DEGREE_OF_FREEDOM%; %VARIABLE2_DEGREE_OF_FREEDOM%)");
143 aOutput.writeFormula(aTemplate.getTemplate());
144 aTemplate.autoReplaceAddress("%P_RIGHT_TAIL_VALUE%", aOutput.current());
145 aOutput.newLine();
147 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_F_CRITICAL_RIGHT_TAIL));
148 aOutput.nextColumn();
149 aTemplate.setTemplate("=FINV(%ALPHA%; %VARIABLE1_DEGREE_OF_FREEDOM%; %VARIABLE2_DEGREE_OF_FREEDOM%)");
150 aOutput.writeFormula(aTemplate.getTemplate());
151 aOutput.newLine();
153 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_P_LEFT_TAIL));
154 aOutput.nextColumn();
155 aTemplate.setTemplate("=1 - %P_RIGHT_TAIL_VALUE%");
156 aOutput.writeFormula(aTemplate.getTemplate());
157 aTemplate.autoReplaceAddress("%P_LEFT_TAIL_VALUE%", aOutput.current());
158 aOutput.newLine();
160 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_F_CRITICAL_LEFT_TAIL));
161 aOutput.nextColumn();
162 aTemplate.setTemplate("=FINV(1-%ALPHA%; %VARIABLE1_DEGREE_OF_FREEDOM%; %VARIABLE2_DEGREE_OF_FREEDOM%)");
163 aOutput.writeFormula(aTemplate.getTemplate());
164 aOutput.newLine();
166 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_P_TWO_TAIL));
167 aOutput.nextColumn();
168 aTemplate.setTemplate("=2*MIN(%P_RIGHT_TAIL_VALUE%; %P_LEFT_TAIL_VALUE%)");
169 aOutput.writeFormula(aTemplate.getTemplate());
170 aOutput.newLine();
172 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_F_CRITICAL_TWO_TAIL));
173 aOutput.nextColumn();
174 aTemplate.setTemplate("=FINV(1-(%ALPHA%/2); %VARIABLE1_DEGREE_OF_FREEDOM%; %VARIABLE2_DEGREE_OF_FREEDOM%)");
175 aOutput.writeFormula(aTemplate.getTemplate());
176 aOutput.nextColumn();
177 aTemplate.setTemplate("=FINV(%ALPHA%/2; %VARIABLE1_DEGREE_OF_FREEDOM%; %VARIABLE2_DEGREE_OF_FREEDOM%)");
178 aOutput.writeFormula(aTemplate.getTemplate());
180 return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress);
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */