tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / StatisticsDialogs / ChiSquareTestDialog.cxx
blob5c1ada025aa8f9f36dafd32e96333821f3c020a6
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 <reffact.hxx>
12 #include <TableFillingAndNavigationTools.hxx>
13 #include <ChiSquareTestDialog.hxx>
14 #include <scresid.hxx>
15 #include <strings.hrc>
17 ScChiSquareTestDialog::ScChiSquareTestDialog(
18 SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
19 weld::Window* pParent, ScViewData& rViewData ) :
20 ScStatisticsInputOutputDialog(
21 pSfxBindings, pChildWindow, pParent, rViewData,
22 u"modules/scalc/ui/chisquaretestdialog.ui"_ustr, u"ChiSquareTestDialog"_ustr)
24 m_xDialog->set_title(ScResId(STR_CHI_SQUARE_TEST));
27 ScChiSquareTestDialog::~ScChiSquareTestDialog()
30 void ScChiSquareTestDialog::Close()
32 DoClose(ScChiSquareTestDialogWrapper::GetChildWindowId());
35 TranslateId ScChiSquareTestDialog::GetUndoNameId()
37 return STR_CHI_SQUARE_TEST;
40 ScRange ScChiSquareTestDialog::ApplyOutput(ScDocShell* pDocShell)
42 AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument,
43 formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
44 FormulaTemplate aTemplate(&mDocument);
46 aTemplate.autoReplaceRange(u"%RANGE%"_ustr, mInputRange);
48 aOutput.writeBoldString(ScResId(STR_CHI_SQUARE_TEST));
49 aOutput.newLine();
51 // Alpha
52 aOutput.writeString(ScResId(STR_LABEL_ALPHA));
53 aOutput.nextColumn();
54 aOutput.writeValue(0.05);
55 aTemplate.autoReplaceAddress(u"%ALPHA%"_ustr, aOutput.current());
56 aOutput.newLine();
58 // DF
59 aOutput.writeString(ScResId(STR_DEGREES_OF_FREEDOM_LABEL));
60 aOutput.nextColumn();
61 aTemplate.setTemplate("=(COLUMNS(%RANGE%) - 1) * (ROWS(%RANGE%) - 1)");
62 aTemplate.autoReplaceAddress(u"%DEGREES_OF_FREEDOM%"_ustr, aOutput.current());
63 aOutput.writeFormula(aTemplate.getTemplate());
64 aOutput.newLine();
66 // p Value
67 aOutput.writeString(ScResId(STR_P_VALUE_LABEL));
68 aOutput.nextColumn();
69 aTemplate.setTemplate("=CHITEST(%RANGE%; MMULT(MMULT(%RANGE%;TRANSPOSE(IF(COLUMN(%RANGE%))));MMULT(TRANSPOSE(IF(ROW(%RANGE%)));%RANGE%)) / SUM(%RANGE%))");
70 aTemplate.autoReplaceAddress(u"%P_VALUE%"_ustr, aOutput.current());
71 aOutput.writeFormula(aTemplate.getTemplate());
72 aOutput.newLine();
74 // Test Statistic
75 aOutput.writeString(ScResId(STR_TEST_STATISTIC_LABEL));
76 aOutput.nextColumn();
77 aTemplate.setTemplate("=CHIINV(%P_VALUE%; %DEGREES_OF_FREEDOM%)");
78 aOutput.writeFormula(aTemplate.getTemplate());
79 aOutput.newLine();
81 // Critical value
82 aOutput.writeString(ScResId(STR_CRITICAL_VALUE_LABEL));
83 aOutput.nextColumn();
84 aTemplate.setTemplate("=CHIINV(%ALPHA%; %DEGREES_OF_FREEDOM%)");
85 aOutput.writeFormula(aTemplate.getTemplate());
86 aOutput.newLine();
88 return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress);
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */