fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / StatisticsDialogs / ChiSquareTestDialog.cxx
blob1e6483d7ea35777ad4c196bcd7ad8a2356e1f31f
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 "ChiSquareTestDialog.hxx"
31 ScChiSquareTestDialog::ScChiSquareTestDialog(
32 SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
33 vcl::Window* pParent, ScViewData* pViewData ) :
34 ScStatisticsInputOutputDialog(
35 pSfxBindings, pChildWindow, pParent, pViewData,
36 "ChiSquareTestDialog", "modules/scalc/ui/chisquaretestdialog.ui" )
38 SetText(SC_STRLOAD(RID_STATISTICS_DLGS, STR_CHI_SQUARE_TEST));
41 ScChiSquareTestDialog::~ScChiSquareTestDialog()
44 bool ScChiSquareTestDialog::Close()
46 return DoClose(ScChiSquareTestDialogWrapper::GetChildWindowId());
49 sal_Int16 ScChiSquareTestDialog::GetUndoNameId()
51 return STR_CHI_SQUARE_TEST;
54 ScRange ScChiSquareTestDialog::ApplyOutput(ScDocShell* pDocShell)
56 AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument,
57 formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
58 FormulaTemplate aTemplate(mDocument);
60 aTemplate.autoReplaceRange("%RANGE%", mInputRange);
62 aOutput.writeBoldString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_CHI_SQUARE_TEST));
63 aOutput.newLine();
65 // Alpha
66 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_LABEL_ALPHA));
67 aOutput.nextColumn();
68 aOutput.writeValue(0.05);
69 aTemplate.autoReplaceAddress("%ALPHA%", aOutput.current());
70 aOutput.newLine();
72 // DF
73 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_DEGREES_OF_FREEDOM_LABEL));
74 aOutput.nextColumn();
75 aTemplate.setTemplate("=(COLUMNS(%RANGE%) - 1) * (ROWS(%RANGE%) - 1)");
76 aTemplate.autoReplaceAddress("%DEGREES_OF_FREEDOM%", aOutput.current());
77 aOutput.writeFormula(aTemplate.getTemplate());
78 aOutput.newLine();
80 // p Value
81 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_P_VALUE_LABEL));
82 aOutput.nextColumn();
83 aTemplate.setTemplate("=CHITEST(%RANGE%; MMULT(MMULT(%RANGE%;TRANSPOSE(IF(COLUMN(%RANGE%))));MMULT(TRANSPOSE(IF(ROW(%RANGE%)));%RANGE%)) / SUM(%RANGE%))");
84 aTemplate.autoReplaceAddress("%P_VALUE%", aOutput.current());
85 aOutput.writeFormula(aTemplate.getTemplate());
86 aOutput.newLine();
88 // Test Statistic
89 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_TEST_STATISTIC_LABEL));
90 aOutput.nextColumn();
91 aTemplate.setTemplate("=CHIINV(%P_VALUE%; %DEGREES_OF_FREEDOM%)");
92 aOutput.writeFormula(aTemplate.getTemplate());
93 aOutput.newLine();
95 // Critical value
96 aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_CRITICAL_VALUE_LABEL));
97 aOutput.nextColumn();
98 aTemplate.setTemplate("=CHIINV(%ALPHA%; %DEGREES_OF_FREEDOM%)");
99 aOutput.writeFormula(aTemplate.getTemplate());
100 aOutput.newLine();
102 return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress);
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */