LibreOffice Module sc (master) 1
ChiSquareTestDialog.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 */
10
11#include <reffact.hxx>
14#include <scresid.hxx>
15#include <strings.hrc>
16
18 SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
19 weld::Window* pParent, ScViewData& rViewData ) :
21 pSfxBindings, pChildWindow, pParent, rViewData,
22 "modules/scalc/ui/chisquaretestdialog.ui", "ChiSquareTestDialog")
23{
24 m_xDialog->set_title(ScResId(STR_CHI_SQUARE_TEST));
25}
26
28{}
29
31{
33}
34
36{
37 return STR_CHI_SQUARE_TEST;
38}
39
41{
44 FormulaTemplate aTemplate(&mDocument);
45
46 aTemplate.autoReplaceRange("%RANGE%", mInputRange);
47
48 aOutput.writeBoldString(ScResId(STR_CHI_SQUARE_TEST));
49 aOutput.newLine();
50
51 // Alpha
52 aOutput.writeString(ScResId(STR_LABEL_ALPHA));
53 aOutput.nextColumn();
54 aOutput.writeValue(0.05);
55 aTemplate.autoReplaceAddress("%ALPHA%", aOutput.current());
56 aOutput.newLine();
57
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("%DEGREES_OF_FREEDOM%", aOutput.current());
63 aOutput.writeFormula(aTemplate.getTemplate());
64 aOutput.newLine();
65
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("%P_VALUE%", aOutput.current());
71 aOutput.writeFormula(aTemplate.getTemplate());
72 aOutput.newLine();
73
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();
80
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();
87
88 return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress);
89}
90
91/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
void writeFormula(const OUString &aFormula)
void writeBoldString(const OUString &aString)
void writeString(const OUString &aString)
ScAddress current(SCCOL aRelativeCol=0, SCROW aRelativeRow=0, SCTAB aRelativeTab=0)
void setTemplate(const OUString &aTemplate)
void autoReplaceAddress(const OUString &aVariable, ScAddress const &aAddress)
void autoReplaceRange(const OUString &aVariable, const ScRange &rRange)
virtual void Close() override
ScChiSquareTestDialog(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent, ScViewData &rViewData)
virtual ~ScChiSquareTestDialog() override
virtual ScRange ApplyOutput(ScDocShell *pDocShell) override
virtual TranslateId GetUndoNameId() override
bool DoClose(sal_uInt16 nId)
Definition: anyrefdg.cxx:714
static Grammar mergeToGrammar(const Grammar eGrammar, const AddressConvention eConv)
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
formula::FormulaGrammar::AddressConvention eConv
Definition: address.hxx:225