diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-11-08 18:50:08 +0100 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-11-08 19:39:15 +0100 |
commit | be8a5d4495e787e1628bf053be5e3e56e0ea9565 (patch) | |
tree | b4f2f74355706875e24eaa0e38dae6c563e519d3 | |
parent | 1e81e82a3f49bf2482bd28948154724c2ee5124f (diff) |
tdf#74667 Regression dialog: linear, logarithmic, power
Add a new statistics dialog for calculating regression. First
supported regression models are linear, logarithmic and power.
Change-Id: I6fa18136455d4bc4d69edbaa7d19ee6b5b6e5703
-rw-r--r-- | officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu | 8 | ||||
-rw-r--r-- | sc/Library_sc.mk | 1 | ||||
-rw-r--r-- | sc/UIConfig_scalc.mk | 1 | ||||
-rw-r--r-- | sc/inc/sc.hrc | 11 | ||||
-rw-r--r-- | sc/sdi/cellsh.sdi | 1 | ||||
-rw-r--r-- | sc/sdi/scalc.sdi | 24 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/RegressionDialog.cxx | 232 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/StatisticsDialogs.hrc | 25 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/StatisticsDialogs.src | 40 | ||||
-rw-r--r-- | sc/source/ui/app/scdll.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/RegressionDialog.hxx | 39 | ||||
-rw-r--r-- | sc/source/ui/inc/reffact.hxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshc.cxx | 7 | ||||
-rw-r--r-- | sc/uiconfig/scalc/menubar/menubar.xml | 1 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/regressiondialog.ui | 404 |
17 files changed, 800 insertions, 12 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index c18bd3cc405c..fb1536974b3b 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -744,6 +744,14 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:RegressionDialog" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">~Regression...</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> <node oor:name=".uno:TTestDialog" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">~t-test...</value> diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 4923a7149522..8304a9adf44d 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -508,6 +508,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator \ sc/source/ui/StatisticsDialogs/MovingAverageDialog \ sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog \ + sc/source/ui/StatisticsDialogs/RegressionDialog \ sc/source/ui/StatisticsDialogs/SamplingDialog \ sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog \ sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog \ diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk index 5e4be535bf32..051e2bf15270 100644 --- a/sc/UIConfig_scalc.mk +++ b/sc/UIConfig_scalc.mk @@ -138,6 +138,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\ sc/uiconfig/scalc/ui/protectsheetdlg \ sc/uiconfig/scalc/ui/queryrunstreamscriptdialog \ sc/uiconfig/scalc/ui/randomnumbergenerator \ + sc/uiconfig/scalc/ui/regressiondialog \ sc/uiconfig/scalc/ui/retypepassdialog \ sc/uiconfig/scalc/ui/retypepassworddialog \ sc/uiconfig/scalc/ui/rightfooterdialog \ diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index c332cd2d0e33..f49b3fd3e9f9 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -269,11 +269,12 @@ #define SID_COVARIANCE_DIALOG (SC_MESSAGE_START + 75) #define SID_EXPONENTIAL_SMOOTHING_DIALOG (SC_MESSAGE_START + 76) #define SID_MOVING_AVERAGE_DIALOG (SC_MESSAGE_START + 77) -#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_CHI_SQUARE_TEST_DIALOG (SC_MESSAGE_START + 81) -#define SID_SEARCH_RESULTS_DIALOG (SC_MESSAGE_START + 82) +#define SID_REGRESSION_DIALOG (SC_MESSAGE_START + 78) +#define SID_TTEST_DIALOG (SC_MESSAGE_START + 79) +#define SID_FTEST_DIALOG (SC_MESSAGE_START + 80) +#define SID_ZTEST_DIALOG (SC_MESSAGE_START + 81) +#define SID_CHI_SQUARE_TEST_DIALOG (SC_MESSAGE_START + 82) +#define SID_SEARCH_RESULTS_DIALOG (SC_MESSAGE_START + 83) // functions diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi index f043ebd0cb7d..346baa69b75c 100644 --- a/sc/sdi/cellsh.sdi +++ b/sc/sdi/cellsh.sdi @@ -162,6 +162,7 @@ interface CellSelection SID_CORRELATION_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_COVARIANCE_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_EXPONENTIAL_SMOOTHING_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] + SID_REGRESSION_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_MOVING_AVERAGE_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_TTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] SID_FTEST_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ] diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index a33801ba923f..dd91da265781 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -3159,6 +3159,30 @@ SfxVoidItem MovingAverageDialog SID_MOVING_AVERAGE_DIALOG GroupId = GID_OPTIONS; ] +SfxVoidItem RegressionDialog SID_REGRESSION_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 TTestDialog SID_TTEST_DIALOG () [ diff --git a/sc/source/ui/StatisticsDialogs/RegressionDialog.cxx b/sc/source/ui/StatisticsDialogs/RegressionDialog.cxx new file mode 100644 index 000000000000..b6a5b6dfb46b --- /dev/null +++ b/sc/source/ui/StatisticsDialogs/RegressionDialog.cxx @@ -0,0 +1,232 @@ +/* -*- 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 "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 "RegressionDialog.hxx" + +namespace +{ + sal_Int16 constRegressionModel[] = + { + STR_LABEL_LINEAR, + STR_LABEL_LOGARITHMIC, + STR_LABEL_POWER + }; + + OUString constTemplateRSQUARED[] = + { + "=RSQ(%VARIABLE2_RANGE% ; %VARIABLE1_RANGE%)", + "=RSQ(%VARIABLE2_RANGE% ; LN(%VARIABLE1_RANGE%))", + "=RSQ(LN(%VARIABLE2_RANGE%) ; LN(%VARIABLE1_RANGE%))" + }; + + OUString constTemplatesSTDERR[] = + { + "=STEYX(%VARIABLE2_RANGE% ; %VARIABLE1_RANGE%)", + "=STEYX(%VARIABLE2_RANGE% ; LN(%VARIABLE1_RANGE%))", + "=STEYX(LN(%VARIABLE2_RANGE%) ; LN(%VARIABLE1_RANGE%))" + }; + + OUString constTemplatesSLOPE[] = + { + "=SLOPE(%VARIABLE2_RANGE% ; %VARIABLE1_RANGE%)", + "=SLOPE(%VARIABLE2_RANGE% ; LN(%VARIABLE1_RANGE%))", + "=EXP(INTERCEPT(LN(%VARIABLE2_RANGE%) ; LN(%VARIABLE1_RANGE%)))" + }; + + OUString constTemplatesINTERCEPT[] = + { + "=INTERCEPT(%VARIABLE2_RANGE% ; %VARIABLE1_RANGE%)", + "=INTERCEPT(%VARIABLE2_RANGE% ; LN(%VARIABLE1_RANGE%))", + "=SLOPE(LN(%VARIABLE2_RANGE%) ; LN(%VARIABLE1_RANGE%))" + }; + + OUString constRegressionFormula[] = + { + "=%A% * %ADDRESS% + %B%", + "=%A% * LN(%ADDRESS%) + %B%", + "=%A% * %ADDRESS% ^ %B%" + }; + +} // end anonymous namespace + +ScRegressionDialog::ScRegressionDialog( + SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, + vcl::Window* pParent, ScViewData* pViewData ) : + ScStatisticsTwoVariableDialog( + pSfxBindings, pChildWindow, pParent, pViewData, + "RegressionDialog", "modules/scalc/ui/regressiondialog.ui" ) +{ + get(mpLinearCheckBox, "linear-check"); + get(mpLogarithmicCheckBox, "logarithmic-check"); + get(mpPowerCheckBox, "power-check"); +} + +ScRegressionDialog::~ScRegressionDialog() +{} + +bool ScRegressionDialog::Close() +{ + return DoClose(ScRegressionDialogWrapper::GetChildWindowId()); +} + +sal_Int16 ScRegressionDialog::GetUndoNameId() +{ + return STR_REGRESSION_UNDO_NAME; +} + +ScRange ScRegressionDialog::ApplyOutput(ScDocShell* pDocShell) +{ + AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument, + formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv)); + FormulaTemplate aTemplate(mDocument); + aTemplate.autoReplaceUses3D(false); + + std::unique_ptr<DataRangeIterator> pVariable1Iterator; + if (mGroupedBy == BY_COLUMN) + pVariable1Iterator.reset(new DataRangeByColumnIterator(mVariable1Range)); + else + pVariable1Iterator.reset(new DataRangeByRowIterator(mVariable1Range)); + + std::unique_ptr<DataRangeIterator> pVariable2Iterator; + if (mGroupedBy == BY_COLUMN) + pVariable2Iterator.reset(new DataRangeByColumnIterator(mVariable2Range)); + else + pVariable2Iterator.reset(new DataRangeByRowIterator(mVariable2Range)); + + aTemplate.autoReplaceRange("%VARIABLE1_RANGE%", pVariable1Iterator->get()); + aTemplate.autoReplaceRange("%VARIABLE2_RANGE%", pVariable2Iterator->get()); + + aOutput.writeBoldString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_REGRESSION)); + aOutput.newLine(); + aOutput.newLine(); + aOutput.push(); + + // REGRESSION MODEL + aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_LABEL_REGRESSION_MODEL)); + aOutput.nextRow(); + + // RSQUARED + aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_LABEL_RSQUARED)); + aOutput.nextRow(); + + // Standard Error + aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STRID_CALC_STD_ERROR)); + aOutput.nextRow(); + + aOutput.nextRow(); + + // Slope + aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_LABEL_SLOPE)); + aOutput.nextRow(); + + // Intercept + aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_LABEL_INTERCEPT)); + aOutput.nextRow(); + + aOutput.nextRow(); + + size_t nVariable1Size = pVariable1Iterator->size(); + + OUString sFormula; + if (mGroupedBy == BY_COLUMN) + sFormula = "=INDEX(%VARIABLE1_RANGE%; %VAR1_CELL_INDEX%; 1)"; + else + sFormula = "=INDEX(%VARIABLE1_RANGE%; 1; %VAR1_CELL_INDEX%)"; + + for (size_t i = 0; i < nVariable1Size; i++) + { + aTemplate.setTemplate(sFormula); + aTemplate.applyNumber("%VAR1_CELL_INDEX%", i + 1); + aOutput.writeFormula(aTemplate.getTemplate()); + aOutput.nextRow(); + } + + aOutput.reset(); + + bool aEnabledRegressionTypes[3]; + + aEnabledRegressionTypes[0] = mpLinearCheckBox->IsChecked(); + aEnabledRegressionTypes[1] = mpLogarithmicCheckBox->IsChecked(); + aEnabledRegressionTypes[2] = mpPowerCheckBox->IsChecked(); + + sal_Int16 nColumn = 0; + + for (size_t nRegressionIndex = 0; nRegressionIndex < SAL_N_ELEMENTS(aEnabledRegressionTypes); ++nRegressionIndex) + { + if (!aEnabledRegressionTypes[nRegressionIndex]) + continue; + + aOutput.nextColumn(); + nColumn += 1; + + // REGRESSION MODEL + aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, constRegressionModel[nRegressionIndex])); + aOutput.nextRow(); + + // RSQUARED + aTemplate.setTemplate(constTemplateRSQUARED[nRegressionIndex]); + aOutput.writeMatrixFormula(aTemplate.getTemplate()); + aTemplate.autoReplaceAddress("%RSQUARED%", aOutput.current()); + aOutput.nextRow(); + + // Standard Error + aTemplate.setTemplate(constTemplatesSTDERR[nRegressionIndex]); + aOutput.writeMatrixFormula(aTemplate.getTemplate()); + aTemplate.autoReplaceAddress("%STD_ERROR%", aOutput.current()); + aOutput.nextRow(); + + aOutput.nextRow(); + + // Slope + aTemplate.setTemplate(constTemplatesSLOPE[nRegressionIndex]); + aOutput.writeMatrixFormula(aTemplate.getTemplate()); + aTemplate.autoReplaceAddress("%A%", aOutput.current()); + aOutput.nextRow(); + + // Intercept + aTemplate.setTemplate(constTemplatesINTERCEPT[nRegressionIndex]); + aOutput.writeMatrixFormula(aTemplate.getTemplate()); + aTemplate.autoReplaceAddress("%B%", aOutput.current()); + aOutput.nextRow(); + + aOutput.nextRow(); + + for (size_t i = 0; i < nVariable1Size; i++) + { + aTemplate.setTemplate(constRegressionFormula[nRegressionIndex]); + aTemplate.applyAddress("%ADDRESS%", aOutput.current(-nColumn), false); + aOutput.writeFormula(aTemplate.getTemplate()); + + aOutput.nextRow(); + } + + aOutput.resetRow(); + } + + return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/StatisticsDialogs.hrc b/sc/source/ui/StatisticsDialogs/StatisticsDialogs.hrc index 662dc6dfd416..f8cbcbbdc4fe 100644 --- a/sc/source/ui/StatisticsDialogs/StatisticsDialogs.hrc +++ b/sc/source/ui/StatisticsDialogs/StatisticsDialogs.hrc @@ -55,13 +55,15 @@ #define STR_COVARIANCE_UNDO_NAME 63 #define STR_EXPONENTIAL_SMOOTHING_UNDO_NAME 64 #define STR_MOVING_AVERAGE_UNDO_NAME 65 -#define STR_TTEST 66 -#define STR_TTEST_UNDO_NAME 67 -#define STR_FTEST 68 -#define STR_FTEST_UNDO_NAME 69 -#define STR_ZTEST 70 -#define STR_ZTEST_UNDO_NAME 71 -#define STR_CHI_SQUARE_TEST 72 +#define STR_REGRESSION 66 +#define STR_REGRESSION_UNDO_NAME 67 +#define STR_TTEST 68 +#define STR_TTEST_UNDO_NAME 69 +#define STR_FTEST 70 +#define STR_FTEST_UNDO_NAME 71 +#define STR_ZTEST 72 +#define STR_ZTEST_UNDO_NAME 73 +#define STR_CHI_SQUARE_TEST 74 #define STR_COLUMN_LABEL_TEMPLATE 100 #define STR_ROW_LABEL_TEMPLATE 101 @@ -93,6 +95,15 @@ #define STR_CRITICAL_VALUE_LABEL 150 #define STR_TEST_STATISTIC_LABEL 151 +#define STR_LABEL_LINEAR 160 +#define STR_LABEL_LOGARITHMIC 161 +#define STR_LABEL_POWER 162 + +#define STR_LABEL_REGRESSION_MODEL 170 +#define STR_LABEL_RSQUARED 171 +#define STR_LABEL_SLOPE 172 +#define STR_LABEL_INTERCEPT 173 + #define STR_FTEST_P_RIGHT_TAIL 200 #define STR_FTEST_F_CRITICAL_RIGHT_TAIL 201 #define STR_FTEST_P_LEFT_TAIL 202 diff --git a/sc/source/ui/StatisticsDialogs/StatisticsDialogs.src b/sc/source/ui/StatisticsDialogs/StatisticsDialogs.src index 501e443aa761..d807e4d1e673 100644 --- a/sc/source/ui/StatisticsDialogs/StatisticsDialogs.src +++ b/sc/source/ui/StatisticsDialogs/StatisticsDialogs.src @@ -305,6 +305,14 @@ Resource RID_STATISTICS_DLGS { Text [ en-US ] = "Test of Independence (Chi-Square)"; }; + String STR_REGRESSION_UNDO_NAME + { + Text [ en-US ] = "Regression"; + }; + String STR_REGRESSION + { + Text [ en-US ] = "Regression"; + }; /* Common */ String STR_COLUMN_LABEL_TEMPLATE @@ -356,6 +364,38 @@ Resource RID_STATISTICS_DLGS Text [ en-US ] = "Test Statistic"; }; + /* RegressionDialog */ + + String STR_LABEL_LINEAR + { + Text [ en-US ] = "Linear"; + }; + String STR_LABEL_LOGARITHMIC + { + Text [ en-US ] = "Logarithmic"; + }; + String STR_LABEL_POWER + { + Text [ en-US ] = "Power"; + }; + + String STR_LABEL_REGRESSION_MODEL + { + Text [ en-US ] = "Regression Model"; + }; + String STR_LABEL_RSQUARED + { + Text [ en-US ] = "R^2"; + }; + String STR_LABEL_SLOPE + { + Text [ en-US ] = "Slope"; + }; + String STR_LABEL_INTERCEPT + { + Text [ en-US ] = "Intercept"; + }; + /*F Test */ String STR_FTEST_P_RIGHT_TAIL { diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx index c9761f5c9527..56cfc4527814 100644 --- a/sc/source/ui/app/scdll.cxx +++ b/sc/source/ui/app/scdll.cxx @@ -243,6 +243,7 @@ void ScDLL::Init() ScCovarianceDialogWrapper ::RegisterChildWindow(false, pMod); ScExponentialSmoothingDialogWrapper ::RegisterChildWindow(false, pMod); ScMovingAverageDialogWrapper ::RegisterChildWindow(false, pMod); + ScRegressionDialogWrapper ::RegisterChildWindow(false, pMod); ScTTestDialogWrapper ::RegisterChildWindow(false, pMod); ScFTestDialogWrapper ::RegisterChildWindow(false, pMod); ScZTestDialogWrapper ::RegisterChildWindow(false, pMod); diff --git a/sc/source/ui/inc/RegressionDialog.hxx b/sc/source/ui/inc/RegressionDialog.hxx new file mode 100644 index 000000000000..a4c7089382e0 --- /dev/null +++ b/sc/source/ui/inc/RegressionDialog.hxx @@ -0,0 +1,39 @@ +/* -*- 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_REGRESSIONDIALOG_HXX +#define INCLUDED_SC_SOURCE_UI_INC_REGRESSIONDIALOG_HXX + +#include "StatisticsTwoVariableDialog.hxx" + +class ScRegressionDialog : public ScStatisticsTwoVariableDialog +{ + VclPtr<CheckBox> mpLinearCheckBox; + VclPtr<CheckBox> mpLogarithmicCheckBox; + VclPtr<CheckBox> mpPowerCheckBox; + +public: + ScRegressionDialog( + SfxBindings* pB, SfxChildWindow* pCW, + vcl::Window* pParent, ScViewData* pViewData ); + + virtual ~ScRegressionDialog(); + + virtual bool Close() override; + +protected: + virtual sal_Int16 GetUndoNameId() override; + virtual ScRange ApplyOutput(ScDocShell* pDocShell) override; +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx index 4c6e7339429b..142decf94174 100644 --- a/sc/source/ui/inc/reffact.hxx +++ b/sc/source/ui/inc/reffact.hxx @@ -108,6 +108,13 @@ private: ScMovingAverageDialogWrapper() = delete; }; +class ScRegressionDialogWrapper : + public ChildWindowWrapper<SID_REGRESSION_DIALOG> +{ +private: + ScRegressionDialogWrapper() = delete; +}; + class ScTTestDialogWrapper : public ChildWindowWrapper<SID_TTEST_DIALOG> { diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 4d5d912b7afb..27eb61498720 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -985,6 +985,15 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) pScMod->SetRefDialog( nId, pWnd == nullptr ); } break; + case SID_REGRESSION_DIALOG: + { + sal_uInt16 nId = ScRegressionDialogWrapper::GetChildWindowId(); + SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); + SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); + + pScMod->SetRefDialog( nId, pWnd == nullptr ); + } + break; case SID_TTEST_DIALOG: { sal_uInt16 nId = ScTTestDialogWrapper::GetChildWindowId(); diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx index a765612b2448..f9c6f2048ccd 100644 --- a/sc/source/ui/view/tabvwsh.cxx +++ b/sc/source/ui/view/tabvwsh.cxx @@ -96,6 +96,7 @@ void ScTabViewShell::InitInterface_Impl() GetStaticInterface()->RegisterChildWindow(ScCovarianceDialogWrapper::GetChildWindowId()); GetStaticInterface()->RegisterChildWindow(ScExponentialSmoothingDialogWrapper::GetChildWindowId()); GetStaticInterface()->RegisterChildWindow(ScMovingAverageDialogWrapper::GetChildWindowId()); + GetStaticInterface()->RegisterChildWindow(ScRegressionDialogWrapper::GetChildWindowId()); GetStaticInterface()->RegisterChildWindow(ScTTestDialogWrapper::GetChildWindowId()); GetStaticInterface()->RegisterChildWindow(ScFTestDialogWrapper::GetChildWindowId()); GetStaticInterface()->RegisterChildWindow(ScZTestDialogWrapper::GetChildWindowId()); diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index de6eddcdcad9..67a73b90b428 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -66,6 +66,7 @@ #include "CovarianceDialog.hxx" #include "ExponentialSmoothingDialog.hxx" #include "MovingAverageDialog.hxx" +#include "RegressionDialog.hxx" #include "TTestDialog.hxx" #include "FTestDialog.hxx" #include "ZTestDialog.hxx" @@ -371,6 +372,12 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog( } break; + case SID_REGRESSION_DIALOG: + { + pResult = VclPtr<ScRegressionDialog>::Create( pB, pCW, pParent, &GetViewData() ); + } + break; + case SID_TTEST_DIALOG: { pResult = VclPtr<ScTTestDialog>::Create( pB, pCW, pParent, &GetViewData() ); diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index fe9260f9d020..d1113e4bef29 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -545,6 +545,7 @@ <menu:menuitem menu:id=".uno:CovarianceDialog"/> <menu:menuitem menu:id=".uno:ExponentialSmoothingDialog"/> <menu:menuitem menu:id=".uno:MovingAverageDialog"/> + <menu:menuitem menu:id=".uno:RegressionDialog"/> <menu:menuitem menu:id=".uno:TTestDialog"/> <menu:menuitem menu:id=".uno:FTestDialog"/> <menu:menuitem menu:id=".uno:ZTestDialog"/> diff --git a/sc/uiconfig/scalc/ui/regressiondialog.ui b/sc/uiconfig/scalc/ui/regressiondialog.ui new file mode 100644 index 000000000000..eee5af894009 --- /dev/null +++ b/sc/uiconfig/scalc/ui/regressiondialog.ui @@ -0,0 +1,404 @@ +<?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="RegressionDialog"> + <property name="can_focus">False</property> + <property name="border_width">6</property> + <property name="title" translatable="yes">Regression</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 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="frame-data"> + <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="variable1-range-label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Variable 1 range:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">variable1-range-edit</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="foruilo-RefEdit" id="variable1-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="variable1-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="variable2-range-label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Variable 2 range:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">variable2-range-edit</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="foruilo-RefEdit" id="variable2-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="variable2-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> + <child> + <object class="GtkLabel" id="output-range-label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Results to:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">variable2-range-edit</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</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">2</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">2</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> + <object class="GtkFrame" id="frame-group"> + <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">1</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="frame-param"> + <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="alignment5"> + <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="grid4"> + <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="GtkCheckButton" id="linear-check"> + <property name="label" translatable="yes">Linear Regression</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</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="GtkCheckButton" id="logarithmic-check"> + <property name="label" translatable="yes">Logarithmic Regression</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="power-check"> + <property name="label" translatable="yes">Power Regression</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Output Regression Types</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="variable1-range-label"/> + <widget name="variable2-range-label"/> + <widget name="output-range-label"/> + <widget name="groupedby-columns-radio"/> + </widgets> + </object> +</interface> |