Kaydet (Commit) c080641d authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

fdo#76868 Add chi-square test Statistics Dialog

Change-Id: I35c115a1f1cb733a0d6841596d8baf2e5ade4a1d
üst 5c339be4
...@@ -755,6 +755,14 @@ ...@@ -755,6 +755,14 @@
<value>1</value> <value>1</value>
</prop> </prop>
</node> </node>
<node oor:name=".uno:ChiSquareTestDialog" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Chi-square Test...</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
<node oor:name=".uno:EditHeaderAndFooter" oor:op="replace"> <node oor:name=".uno:EditHeaderAndFooter" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string"> <prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Headers &amp; Footers...</value> <value xml:lang="en-US">~Headers &amp; Footers...</value>
......
...@@ -495,6 +495,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ ...@@ -495,6 +495,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog \ sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog \
sc/source/ui/StatisticsDialogs/CorrelationDialog \ sc/source/ui/StatisticsDialogs/CorrelationDialog \
sc/source/ui/StatisticsDialogs/CovarianceDialog \ sc/source/ui/StatisticsDialogs/CovarianceDialog \
sc/source/ui/StatisticsDialogs/ChiSquareTestDialog \
sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog \ sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog \
sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog \ sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog \
sc/source/ui/StatisticsDialogs/FTestDialog \ sc/source/ui/StatisticsDialogs/FTestDialog \
......
...@@ -67,6 +67,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\ ...@@ -67,6 +67,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/cellprotectionpage \ sc/uiconfig/scalc/ui/cellprotectionpage \
sc/uiconfig/scalc/ui/changesourcedialog \ sc/uiconfig/scalc/ui/changesourcedialog \
sc/uiconfig/scalc/ui/chardialog \ sc/uiconfig/scalc/ui/chardialog \
sc/uiconfig/scalc/ui/chisquaretestdialog \
sc/uiconfig/scalc/ui/colorrowdialog \ sc/uiconfig/scalc/ui/colorrowdialog \
sc/uiconfig/scalc/ui/colwidthdialog \ sc/uiconfig/scalc/ui/colwidthdialog \
sc/uiconfig/scalc/ui/condformatmanager \ sc/uiconfig/scalc/ui/condformatmanager \
......
...@@ -272,7 +272,8 @@ ...@@ -272,7 +272,8 @@
#define SID_TTEST_DIALOG (SC_MESSAGE_START + 78) #define SID_TTEST_DIALOG (SC_MESSAGE_START + 78)
#define SID_FTEST_DIALOG (SC_MESSAGE_START + 79) #define SID_FTEST_DIALOG (SC_MESSAGE_START + 79)
#define SID_ZTEST_DIALOG (SC_MESSAGE_START + 80) #define SID_ZTEST_DIALOG (SC_MESSAGE_START + 80)
#define SID_SEARCH_RESULTS_DIALOG (SC_MESSAGE_START + 81) #define SID_CHI_SQUARE_TEST_DIALOG (SC_MESSAGE_START + 81)
#define SID_SEARCH_RESULTS_DIALOG (SC_MESSAGE_START + 82)
// functions // functions
......
...@@ -162,6 +162,7 @@ interface CellSelection ...@@ -162,6 +162,7 @@ interface CellSelection
SID_TTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_TTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_FTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_FTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_ZTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_ZTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_CHI_SQUARE_TEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_SEARCH_RESULTS_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_SEARCH_RESULTS_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_MARKDATAAREA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ] SID_MARKDATAAREA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
SID_MARKARRAYFORMULA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ] SID_MARKARRAYFORMULA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
......
...@@ -3231,6 +3231,30 @@ SfxVoidItem ZTestDialog SID_ZTEST_DIALOG ...@@ -3231,6 +3231,30 @@ SfxVoidItem ZTestDialog SID_ZTEST_DIALOG
GroupId = GID_OPTIONS; GroupId = GID_OPTIONS;
] ]
SfxVoidItem ChiSquareTestDialog SID_CHI_SQUARE_TEST_DIALOG
()
[
/* flags: */
AutoUpdate = FALSE,
Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = TRUE,
ReadOnlyDoc = TRUE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
Synchron;
/* config: */
AccelConfig = TRUE,
MenuConfig = TRUE,
StatusBarConfig = FALSE,
ToolBoxConfig = TRUE,
GroupId = GID_OPTIONS;
]
SfxVoidItem SolverDialog SID_OPENDLG_OPTSOLVER SfxVoidItem SolverDialog SID_OPENDLG_OPTSOLVER
() ()
[ [
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#include <sfx2/dispatch.hxx>
#include <svl/zforlist.hxx>
#include <svl/undo.hxx>
#include <boost/random.hpp>
#include <boost/scoped_ptr.hpp>
#include "formulacell.hxx"
#include "rangelst.hxx"
#include "scitems.hxx"
#include "docsh.hxx"
#include "document.hxx"
#include "uiitems.hxx"
#include "reffact.hxx"
#include "strload.hxx"
#include "docfunc.hxx"
#include "StatisticsDialogs.hrc"
#include "TableFillingAndNavigationTools.hxx"
#include "ChiSquareTestDialog.hxx"
ScChiSquareTestDialog::ScChiSquareTestDialog(
SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
vcl::Window* pParent, ScViewData* pViewData ) :
ScStatisticsInputOutputDialog(
pSfxBindings, pChildWindow, pParent, pViewData,
"ChiSquareTestDialog", "modules/scalc/ui/chisquaretestdialog.ui" )
{
SetText(SC_STRLOAD(RID_STATISTICS_DLGS, STR_ZTEST));
}
ScChiSquareTestDialog::~ScChiSquareTestDialog()
{}
bool ScChiSquareTestDialog::Close()
{
return DoClose(ScChiSquareTestDialogWrapper::GetChildWindowId());
}
sal_Int16 ScChiSquareTestDialog::GetUndoNameId()
{
return STR_ZTEST_UNDO_NAME;
}
ScRange ScChiSquareTestDialog::ApplyOutput(ScDocShell* pDocShell)
{
AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument,
formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
FormulaTemplate aTemplate(mDocument);
aTemplate.autoReplaceRange("%RANGE%", mInputRange);
aOutput.writeBoldString("Independence Test (Chi-Square)");
aOutput.newLine();
// Alpha
aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_LABEL_ALPHA));
aOutput.nextColumn();
aOutput.writeValue(0.05);
aTemplate.autoReplaceAddress("%ALPHA%", aOutput.current());
aOutput.newLine();
// DF
aOutput.writeString("df");
aOutput.nextColumn();
aTemplate.setTemplate("=(COLUMNS(%RANGE%) - 1) * (ROWS(%RANGE%) - 1)");
aTemplate.autoReplaceAddress("%DEGREES_OF_FREEDOM%", aOutput.current());
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.newLine();
// p Value
aOutput.writeString("P-Value");
aOutput.nextColumn();
aTemplate.setTemplate("=CHITEST(%RANGE%; MMULT(MMULT(%RANGE%;TRANSPOSE(IF(COLUMN(%RANGE%))));MMULT(TRANSPOSE(IF(ROW(%RANGE%)));%RANGE%)) / SUM(%RANGE%))");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.newLine();
// Critical value
aOutput.writeString("Critical Value");
aOutput.nextColumn();
aTemplate.setTemplate("=CHIINV(%ALPHA%; %DEGREES_OF_FREEDOM%)");
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.newLine();
return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -260,6 +260,7 @@ void ScDLL::Init() ...@@ -260,6 +260,7 @@ void ScDLL::Init()
ScTTestDialogWrapper ::RegisterChildWindow(false, pMod); ScTTestDialogWrapper ::RegisterChildWindow(false, pMod);
ScFTestDialogWrapper ::RegisterChildWindow(false, pMod); ScFTestDialogWrapper ::RegisterChildWindow(false, pMod);
ScZTestDialogWrapper ::RegisterChildWindow(false, pMod); ScZTestDialogWrapper ::RegisterChildWindow(false, pMod);
ScChiSquareTestDialogWrapper ::RegisterChildWindow(false, pMod);
// First docking Window for Calc // First docking Window for Calc
ScFunctionChildWindow ::RegisterChildWindow(false, pMod); ScFunctionChildWindow ::RegisterChildWindow(false, pMod);
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#ifndef INCLUDED_SC_SOURCE_UI_INC_CHISQUARETESTDIALOG_HXX
#define INCLUDED_SC_SOURCE_UI_INC_CHISQUARETESTDIALOG_HXX
#include "StatisticsInputOutputDialog.hxx"
class ScChiSquareTestDialog : public ScStatisticsInputOutputDialog
{
public:
ScChiSquareTestDialog(
SfxBindings* pB, SfxChildWindow* pCW,
vcl::Window* pParent, ScViewData* pViewData );
virtual ~ScChiSquareTestDialog();
virtual bool Close() SAL_OVERRIDE;
protected:
virtual sal_Int16 GetUndoNameId() SAL_OVERRIDE;
virtual ScRange ApplyOutput(ScDocShell* pDocShell) SAL_OVERRIDE;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -128,6 +128,13 @@ private: ...@@ -128,6 +128,13 @@ private:
ScZTestDialogWrapper() SAL_DELETED_FUNCTION; ScZTestDialogWrapper() SAL_DELETED_FUNCTION;
}; };
class ScChiSquareTestDialogWrapper :
public ChildWindowWrapper<SID_CHI_SQUARE_TEST_DIALOG>
{
private:
ScChiSquareTestDialogWrapper() SAL_DELETED_FUNCTION;
};
class ScAcceptChgDlgWrapper: public SfxChildWindow class ScAcceptChgDlgWrapper: public SfxChildWindow
{ {
public: public:
......
...@@ -1002,6 +1002,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) ...@@ -1002,6 +1002,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
} }
break; break;
case SID_CHI_SQUARE_TEST_DIALOG:
{
sal_uInt16 nId = ScChiSquareTestDialogWrapper::GetChildWindowId();
SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
}
break;
case SID_SEARCH_RESULTS_DIALOG: case SID_SEARCH_RESULTS_DIALOG:
{ {
......
...@@ -96,6 +96,7 @@ void ScTabViewShell::InitInterface_Impl() ...@@ -96,6 +96,7 @@ void ScTabViewShell::InitInterface_Impl()
GetStaticInterface()->RegisterChildWindow(ScTTestDialogWrapper::GetChildWindowId()); GetStaticInterface()->RegisterChildWindow(ScTTestDialogWrapper::GetChildWindowId());
GetStaticInterface()->RegisterChildWindow(ScFTestDialogWrapper::GetChildWindowId()); GetStaticInterface()->RegisterChildWindow(ScFTestDialogWrapper::GetChildWindowId());
GetStaticInterface()->RegisterChildWindow(ScZTestDialogWrapper::GetChildWindowId()); GetStaticInterface()->RegisterChildWindow(ScZTestDialogWrapper::GetChildWindowId());
GetStaticInterface()->RegisterChildWindow(ScChiSquareTestDialogWrapper::GetChildWindowId());
} }
SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" ) SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" )
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
#include "TTestDialog.hxx" #include "TTestDialog.hxx"
#include "FTestDialog.hxx" #include "FTestDialog.hxx"
#include "ZTestDialog.hxx" #include "ZTestDialog.hxx"
#include "ChiSquareTestDialog.hxx"
#include "PivotLayoutDialog.hxx" #include "PivotLayoutDialog.hxx"
...@@ -388,6 +389,12 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog( ...@@ -388,6 +389,12 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
} }
break; break;
case SID_CHI_SQUARE_TEST_DIALOG:
{
pResult = new ScChiSquareTestDialog( pB, pCW, pParent, &GetViewData() );
}
break;
case SID_OPENDLG_OPTSOLVER: case SID_OPENDLG_OPTSOLVER:
{ {
ScViewData& rViewData = GetViewData(); ScViewData& rViewData = GetViewData();
......
...@@ -508,6 +508,7 @@ ...@@ -508,6 +508,7 @@
<menu:menuitem menu:id=".uno:TTestDialog"/> <menu:menuitem menu:id=".uno:TTestDialog"/>
<menu:menuitem menu:id=".uno:FTestDialog"/> <menu:menuitem menu:id=".uno:FTestDialog"/>
<menu:menuitem menu:id=".uno:ZTestDialog"/> <menu:menuitem menu:id=".uno:ZTestDialog"/>
<menu:menuitem menu:id=".uno:ChiSquareTestDialog"/>
</menu:menupopup> </menu:menupopup>
</menu:menu> </menu:menu>
</menu:menupopup> </menu:menupopup>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment