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 @@
<value>1</value>
</prop>
</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">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Headers &amp; Footers...</value>
......
......@@ -495,6 +495,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog \
sc/source/ui/StatisticsDialogs/CorrelationDialog \
sc/source/ui/StatisticsDialogs/CovarianceDialog \
sc/source/ui/StatisticsDialogs/ChiSquareTestDialog \
sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog \
sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog \
sc/source/ui/StatisticsDialogs/FTestDialog \
......
......@@ -67,6 +67,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/cellprotectionpage \
sc/uiconfig/scalc/ui/changesourcedialog \
sc/uiconfig/scalc/ui/chardialog \
sc/uiconfig/scalc/ui/chisquaretestdialog \
sc/uiconfig/scalc/ui/colorrowdialog \
sc/uiconfig/scalc/ui/colwidthdialog \
sc/uiconfig/scalc/ui/condformatmanager \
......
......@@ -272,7 +272,8 @@
#define SID_TTEST_DIALOG (SC_MESSAGE_START + 78)
#define SID_FTEST_DIALOG (SC_MESSAGE_START + 79)
#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
......
......@@ -162,6 +162,7 @@ interface CellSelection
SID_TTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_FTEST_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_MARKDATAAREA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
SID_MARKARRAYFORMULA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
......
......@@ -3231,6 +3231,30 @@ SfxVoidItem ZTestDialog SID_ZTEST_DIALOG
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
()
[
......
/* -*- 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()
ScTTestDialogWrapper ::RegisterChildWindow(false, pMod);
ScFTestDialogWrapper ::RegisterChildWindow(false, pMod);
ScZTestDialogWrapper ::RegisterChildWindow(false, pMod);
ScChiSquareTestDialogWrapper ::RegisterChildWindow(false, pMod);
// First docking Window for Calc
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:
ScZTestDialogWrapper() SAL_DELETED_FUNCTION;
};
class ScChiSquareTestDialogWrapper :
public ChildWindowWrapper<SID_CHI_SQUARE_TEST_DIALOG>
{
private:
ScChiSquareTestDialogWrapper() SAL_DELETED_FUNCTION;
};
class ScAcceptChgDlgWrapper: public SfxChildWindow
{
public:
......
......@@ -1002,6 +1002,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
}
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:
{
......
......@@ -96,6 +96,7 @@ void ScTabViewShell::InitInterface_Impl()
GetStaticInterface()->RegisterChildWindow(ScTTestDialogWrapper::GetChildWindowId());
GetStaticInterface()->RegisterChildWindow(ScFTestDialogWrapper::GetChildWindowId());
GetStaticInterface()->RegisterChildWindow(ScZTestDialogWrapper::GetChildWindowId());
GetStaticInterface()->RegisterChildWindow(ScChiSquareTestDialogWrapper::GetChildWindowId());
}
SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" )
......
......@@ -69,6 +69,7 @@
#include "TTestDialog.hxx"
#include "FTestDialog.hxx"
#include "ZTestDialog.hxx"
#include "ChiSquareTestDialog.hxx"
#include "PivotLayoutDialog.hxx"
......@@ -388,6 +389,12 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
}
break;
case SID_CHI_SQUARE_TEST_DIALOG:
{
pResult = new ScChiSquareTestDialog( pB, pCW, pParent, &GetViewData() );
}
break;
case SID_OPENDLG_OPTSOLVER:
{
ScViewData& rViewData = GetViewData();
......
......@@ -508,6 +508,7 @@
<menu:menuitem menu:id=".uno:TTestDialog"/>
<menu:menuitem menu:id=".uno:FTestDialog"/>
<menu:menuitem menu:id=".uno:ZTestDialog"/>
<menu:menuitem menu:id=".uno:ChiSquareTestDialog"/>
</menu:menupopup>
</menu:menu>
</menu:menupopup>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkDialog" id="ChiSquareTestDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Chi Square Test</property>
<property name="resizable">False</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkFrame" id="framedata">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">6</property>
<property name="bottom_padding">6</property>
<property name="left_padding">12</property>
<property name="right_padding">12</property>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel" id="input-range-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Input range:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">input-range-edit</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="foruilo-RefEdit" id="input-range-edit">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="invisible_char"></property>
<property name="width_chars">30</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="foruilo-RefButton" id="input-range-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="output-range-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Results to:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">output-range-edit</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="foruilo-RefEdit" id="output-range-edit">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="invisible_char"></property>
<property name="width_chars">30</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="foruilo-RefButton" id="output-range-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Data</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="help">
<property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">6</property>
<property name="bottom_padding">6</property>
<property name="left_padding">12</property>
<property name="right_padding">12</property>
<child>
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkRadioButton" id="groupedby-columns-radio">
<property name="label" translatable="yes">_Columns</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="groupedby-rows-radio">
<property name="label" translatable="yes">_Rows</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">groupedby-columns-radio</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Grouped by</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">ok</action-widget>
</action-widgets>
</object>
<object class="GtkSizeGroup" id="sizegroup1">
<widgets>
<widget name="input-range-label"/>
<widget name="output-range-label"/>
<widget name="groupedby-columns-radio"/>
<widget name="groupedby-rows-radio"/>
</widgets>
</object>
</interface>
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