summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-07-18 21:44:54 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-07-19 16:57:38 +0200
commitfa20e0dd67c1da8fe8653f163e0fc6743934e7ae (patch)
tree44e2dd34dc7b836055541ce55c9d1abc60cf0492 /sc
parentc7005a1b5b89392b82e20f952814fa6d5bc5b06e (diff)
fdo#66477 Add descriptive statistics calculation to Calc.
New menu entry in "Data>>Statistics>>Descriptive Statistics..." to quickly calculate basic statistics for a row of data. These are Mean, Standard Error, Mode, Median, Variance, Standard Deviation, Kurtosis, Skewness, Range, Minimum, Maximum, Sum and Count. Change-Id: I7c4a75adf7731f42f9c7f8e741ff1b5fa245c1c8
Diffstat (limited to 'sc')
-rw-r--r--sc/AllLangResTarget_sc.mk1
-rw-r--r--sc/Library_sc.mk1
-rw-r--r--sc/UIConfig_scalc.mk1
-rw-r--r--sc/inc/globstr.hrc19
-rw-r--r--sc/inc/sc.hrc1
-rw-r--r--sc/sdi/cellsh.sdi1
-rw-r--r--sc/sdi/scalc.sdi24
-rw-r--r--sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx276
-rw-r--r--sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.src92
-rw-r--r--sc/source/ui/app/scdll.cxx1
-rw-r--r--sc/source/ui/inc/DescriptiveStatisticsDialog.hxx78
-rw-r--r--sc/source/ui/inc/reffact.hxx1
-rw-r--r--sc/source/ui/view/cellsh.cxx1
-rw-r--r--sc/source/ui/view/cellsh1.cxx10
-rw-r--r--sc/source/ui/view/reffact.cxx5
-rw-r--r--sc/source/ui/view/tabvwsh.cxx1
-rw-r--r--sc/source/ui/view/tabvwshc.cxx8
-rw-r--r--sc/uiconfig/scalc/menubar/menubar.xml1
-rw-r--r--sc/uiconfig/scalc/ui/descriptivestatisticsdialog.ui191
19 files changed, 712 insertions, 1 deletions
diff --git a/sc/AllLangResTarget_sc.mk b/sc/AllLangResTarget_sc.mk
index 4de23aa4fa0f..7f6095eae7d3 100644
--- a/sc/AllLangResTarget_sc.mk
+++ b/sc/AllLangResTarget_sc.mk
@@ -85,6 +85,7 @@ $(eval $(call gb_SrsTarget_add_files,sc/res,\
sc/source/ui/sidebar/CellAppearancePropertyPanel.src \
sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.src \
sc/source/ui/StatisticsDialogs/SamplingDialog.src \
+ sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.src \
sc/source/core/src/compiler.src \
))
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 76382ddc4ef3..c192566814e1 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -475,6 +475,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/sidebar/ScPanelFactory \
sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog \
sc/source/ui/StatisticsDialogs/SamplingDialog \
+ sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog \
sc/source/ui/undo/areasave \
sc/source/ui/undo/refundo \
sc/source/ui/undo/target \
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index a740f25cd8e1..f14e8dcb2985 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -67,6 +67,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/definename \
sc/uiconfig/scalc/ui/deletecells \
sc/uiconfig/scalc/ui/deletecontents \
+ sc/uiconfig/scalc/ui/descriptivestatisticsdialog \
sc/uiconfig/scalc/ui/externaldata \
sc/uiconfig/scalc/ui/footerdialog \
sc/uiconfig/scalc/ui/formatcellsdialog \
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 458e775a1a10..7a7cf0a0deb9 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -704,7 +704,24 @@
#define STR_RNG_PARAMETER_STANDARD_NUMBER_OF_TRIALS 571
#define STR_RNG_PARAMETER_STANDARD_NU_VALUE 572
-#define STR_SAMPLING_UNDO_NAME 573
+#define STR_SAMPLING_UNDO_NAME 573
+
+#define SID_CALC_MEAN 574
+#define SID_CALC_STD_ERROR 575
+#define SID_CALC_MODE 576
+#define SID_CALC_MEDIAN 577
+#define SID_CALC_VARIANCE 578
+#define SID_CALC_STD_DEVIATION 579
+#define SID_CALC_KURTOSIS 580
+#define SID_CALC_SKEWNESS 581
+#define SID_CALC_RANGE 582
+#define SID_CALC_MIN 583
+#define SID_CALC_MAX 584
+#define SID_CALC_SUM 585
+#define SID_CALC_COUNT 586
+
+#define STR_DESCRIPTIVE_STATISTICS_UNDO_NAME 587
+
#endif
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 35e6d05fa656..d075e045d235 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -254,6 +254,7 @@
#define SID_OPENDLG_RANDOM_NUMBER_GENERATOR (SC_MESSAGE_START + 70)
#define SID_SAMPLING_DIALOG (SC_MESSAGE_START + 71)
+#define SID_DESCRIPTIVE_STATISTICS_DIALOG (SC_MESSAGE_START + 72)
// functions
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index bf98c9485016..07fce83d1ae6 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -149,6 +149,7 @@ interface CellSelection
FID_FILL_AUTO [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
SID_OPENDLG_RANDOM_NUMBER_GENERATOR [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_SAMPLING_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
+ SID_DESCRIPTIVE_STATISTICS_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_MARKDATAAREA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
SID_MARKARRAYFORMULA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
SID_SETINPUTMODE [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 5e7fcbd540a1..7ac69ac9fb30 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -2990,6 +2990,30 @@ SfxVoidItem SamplingDialog SID_SAMPLING_DIALOG
GroupId = GID_OPTIONS;
]
+SfxVoidItem DescriptiveStatisticsDialog SID_DESCRIPTIVE_STATISTICS_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
()
diff --git a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx
new file mode 100644
index 000000000000..b2df789e5424
--- /dev/null
+++ b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx
@@ -0,0 +1,276 @@
+/* -*- 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 "scresid.hxx"
+#include "random.hxx"
+#include "docfunc.hxx"
+#include "globstr.hrc"
+#include "sc.hrc"
+
+#include <boost/random.hpp>
+
+#include "DescriptiveStatisticsDialog.hxx"
+
+#define ABS_DREF3D SCA_VALID | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_TAB_3D
+
+namespace
+{
+struct StatisticCalculation {
+ const sal_Int16 aCalculationNameId;
+ const char* aFormula;
+};
+
+static const StatisticCalculation lclCalcDefinitions[] =
+{
+ { SID_CALC_MEAN, "=AVERAGE(%RANGE%)" },
+ { SID_CALC_STD_ERROR, "=SQRT(VAR(%RANGE%)/COUNT(%RANGE%))"},
+ { SID_CALC_MODE, "=MODE(%RANGE%)"},
+ { SID_CALC_MEDIAN, "=MEDIAN(%RANGE%)"},
+ { SID_CALC_VARIANCE, "=VAR(%RANGE%)"},
+ { SID_CALC_STD_DEVIATION, "=STDEV(%RANGE%)"},
+ { SID_CALC_KURTOSIS, "=KURT(%RANGE%)"},
+ { SID_CALC_SKEWNESS, "=SKEW(%RANGE%)"},
+ { SID_CALC_RANGE, "=MAX(%RANGE%)-MIN(%RANGE%)"},
+ { SID_CALC_MIN, "=MIN(%RANGE%)"},
+ { SID_CALC_MAX, "=MAX(%RANGE%)"},
+ { SID_CALC_SUM, "=SUM(%RANGE%)"},
+ { SID_CALC_COUNT, "=COUNT(%RANGE%)" },
+ { 0, NULL }
+};
+
+}
+
+ScDescriptiveStatisticsDialog::ScDescriptiveStatisticsDialog(
+ SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, ScViewData* pViewData ) :
+ ScAnyRefDlg ( pB, pCW, pParent, "DescriptiveStatisticsDialog", "modules/scalc/ui/descriptivestatisticsdialog.ui" ),
+ mViewData ( pViewData ),
+ mDocument ( pViewData->GetDocument() ),
+ mAddressDetails ( mDocument->GetAddressConvention(), 0, 0 ),
+ mCurrentAddress ( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ),
+ mDialogLostFocus( false )
+{
+ get(mpInputRangeLabel, "input-range-label");
+ get(mpInputRangeEdit, "input-range-edit");
+ mpInputRangeEdit->SetReferences(this, mpInputRangeLabel);
+ get(mpInputRangeButton, "input-range-button");
+ mpInputRangeButton->SetReferences(this, mpInputRangeEdit);
+
+ get(mpOutputRangeLabel, "output-range-label");
+ get(mpOutputRangeEdit, "output-range-edit");
+ mpOutputRangeEdit->SetReferences(this, mpOutputRangeLabel);
+ get(mpOutputRangeButton, "output-range-button");
+ mpOutputRangeButton->SetReferences(this, mpOutputRangeEdit);
+
+ get(mpButtonOk, "ok");
+ get(mpButtonApply, "apply");
+ get(mpButtonCancel, "cancel");
+
+ Init();
+ GetRangeFromSelection();
+}
+
+void ScDescriptiveStatisticsDialog::Init()
+{
+ mpButtonOk->SetClickHdl( LINK( this, ScDescriptiveStatisticsDialog, OkClicked ) );
+ mpButtonCancel->SetClickHdl( LINK( this, ScDescriptiveStatisticsDialog, CancelClicked ) );
+ mpButtonApply->SetClickHdl( LINK( this, ScDescriptiveStatisticsDialog, ApplyClicked ) );
+ mpButtonOk->Enable(false);
+ mpButtonApply->Enable(false);
+
+ Link aLink = LINK( this, ScDescriptiveStatisticsDialog, GetFocusHandler );
+ mpInputRangeEdit->SetGetFocusHdl( aLink );
+ mpInputRangeButton->SetGetFocusHdl( aLink );
+ mpOutputRangeEdit->SetGetFocusHdl( aLink );
+ mpOutputRangeButton->SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScDescriptiveStatisticsDialog, LoseFocusHandler );
+ mpInputRangeEdit->SetLoseFocusHdl( aLink );
+ mpInputRangeButton->SetLoseFocusHdl( aLink );
+ mpOutputRangeEdit->SetLoseFocusHdl( aLink );
+ mpOutputRangeButton->SetLoseFocusHdl( aLink );
+
+ mpOutputRangeEdit->GrabFocus();
+}
+
+void ScDescriptiveStatisticsDialog::GetRangeFromSelection()
+{
+ OUString aCurrentString;
+ mViewData->GetSimpleArea(mInputRange);
+ mInputRange.Format(aCurrentString, ABS_DREF3D, mDocument, mAddressDetails);
+ mpInputRangeEdit->SetText(aCurrentString);
+}
+
+ScDescriptiveStatisticsDialog::~ScDescriptiveStatisticsDialog()
+{}
+
+void ScDescriptiveStatisticsDialog::SetActive()
+{
+ if ( mDialogLostFocus )
+ {
+ mDialogLostFocus = false;
+ if( mpActiveEdit )
+ mpActiveEdit->GrabFocus();
+ }
+ else
+ {
+ GrabFocus();
+ }
+ RefInputDone();
+}
+
+sal_Bool ScDescriptiveStatisticsDialog::Close()
+{
+ return DoClose( ScDescriptiveStatisticsDialogWrapper::GetChildWindowId() );
+}
+
+void ScDescriptiveStatisticsDialog::SetReference( const ScRange& rReferenceRange, ScDocument* pDocument )
+{
+ if ( mpActiveEdit )
+ {
+ if ( rReferenceRange.aStart != rReferenceRange.aEnd )
+ RefInputStart( mpActiveEdit );
+
+ String aReferenceString;
+
+ if ( mpActiveEdit == mpInputRangeEdit )
+ {
+ mInputRange = rReferenceRange;
+ mInputRange.Format( aReferenceString, ABS_DREF3D, pDocument, mAddressDetails );
+ mpInputRangeEdit->SetRefString( aReferenceString );
+ }
+ else if ( mpActiveEdit == mpOutputRangeEdit )
+ {
+ mOutputAddress = rReferenceRange.aStart;
+
+ sal_uInt16 nFormat = ( mOutputAddress.Tab() == mCurrentAddress.Tab() ) ? SCA_ABS : SCA_ABS_3D;
+ mOutputAddress.Format( aReferenceString, nFormat, pDocument, pDocument->GetAddressConvention() );
+ mpOutputRangeEdit->SetRefString( aReferenceString );
+
+ // Enable OK, Cancel if output range is set
+ mpButtonOk->Enable(!mpOutputRangeEdit->GetText().isEmpty());
+ mpButtonApply->Enable(!mpOutputRangeEdit->GetText().isEmpty());
+ }
+ }
+}
+
+void ScDescriptiveStatisticsDialog::ApplyCalculationsFormulas( )
+{
+ OUString aUndo(ScResId(STR_DESCRIPTIVE_STATISTICS_UNDO_NAME));
+ ScDocShell* pDocShell = mViewData->GetDocShell();
+ svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager();
+ pUndoManager->EnterListAction( aUndo, aUndo );
+
+ ScAddress aStart = mInputRange.aStart;
+ ScAddress aEnd = mInputRange.aEnd;
+
+ SCTAB outTab = mOutputAddress.Tab();
+ SCCOL outCol = mOutputAddress.Col();
+ SCROW outRow = mOutputAddress.Row();
+
+ OUString aReferenceString;
+ ScAddress aAddress;
+
+ for (SCROW inTab = aStart.Tab(); inTab <= aEnd.Tab(); inTab++)
+ {
+ outCol = mOutputAddress.Col();
+
+ for(sal_Int32 i = 0; lclCalcDefinitions[i].aFormula != NULL; i++)
+ {
+ aAddress = ScAddress(outCol, outRow, outTab);
+ OUString aCalculationName(ScResId(lclCalcDefinitions[i].aCalculationNameId));
+ pDocShell->GetDocFunc().SetStringCell(aAddress, aCalculationName, true);
+ outRow++;
+ }
+ outCol++;
+
+ for (SCCOL inCol = aStart.Col(); inCol <= aEnd.Col(); inCol++)
+ {
+ outRow = mOutputAddress.Row();
+ ScRange aColumnRange (
+ ScAddress(inCol, mInputRange.aStart.Row(), inTab),
+ ScAddress(inCol, mInputRange.aEnd.Row(), inTab)
+ );
+
+ aColumnRange.Format( aReferenceString, SCR_ABS, mDocument, mAddressDetails );
+ OUString sRange("%RANGE%");
+ OUString aFormulaString;
+ OUString aFormulaTemplate;
+
+ for(sal_Int32 i = 0; lclCalcDefinitions[i].aFormula != NULL; i++)
+ {
+ aAddress = ScAddress(outCol, outRow, outTab);
+ aFormulaTemplate = OUString::createFromAscii(lclCalcDefinitions[i].aFormula);
+ aFormulaString = aFormulaTemplate.replaceAll(sRange, aReferenceString);
+ pDocShell->GetDocFunc().SetFormulaCell(aAddress, new ScFormulaCell(mDocument, aAddress, aFormulaString), true);
+ outRow++;
+ }
+ outCol++;
+ }
+ outTab++;
+ }
+
+ ScRange aOutputRange(mOutputAddress, ScAddress(outTab, outRow, outTab) );
+ pUndoManager->LeaveListAction();
+ pDocShell->PostPaint( aOutputRange, PAINT_GRID );
+}
+
+IMPL_LINK( ScDescriptiveStatisticsDialog, OkClicked, PushButton*, /*pButton*/ )
+{
+ ApplyClicked(NULL);
+ CancelClicked(NULL);
+ return 0;
+}
+
+
+IMPL_LINK( ScDescriptiveStatisticsDialog, ApplyClicked, PushButton*, /*pButton*/ )
+{
+ ApplyCalculationsFormulas();
+ return 0;
+}
+
+IMPL_LINK( ScDescriptiveStatisticsDialog, CancelClicked, PushButton*, /*pButton*/ )
+{
+ Close();
+ return 0;
+}
+
+IMPL_LINK( ScDescriptiveStatisticsDialog, GetFocusHandler, Control*, pCtrl )
+{
+ mpActiveEdit = NULL;
+
+ if( (pCtrl == (Control*) mpInputRangeEdit) || (pCtrl == (Control*) mpInputRangeButton) )
+ mpActiveEdit = mpInputRangeEdit;
+ else if( (pCtrl == (Control*) mpOutputRangeEdit) || (pCtrl == (Control*) mpOutputRangeButton) )
+ mpActiveEdit = mpOutputRangeEdit;
+
+ if( mpActiveEdit )
+ mpActiveEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+IMPL_LINK_NOARG(ScDescriptiveStatisticsDialog, LoseFocusHandler)
+{
+ mDialogLostFocus = !IsActive();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.src b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.src
new file mode 100644
index 000000000000..af44357dc2db
--- /dev/null
+++ b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.src
@@ -0,0 +1,92 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "globstr.hrc"
+
+String STR_DESCRIPTIVE_STATISTICS_UNDO_NAME
+{
+ Text [ en-US ] = "Descriptive Statistics";
+};
+
+String SID_CALC_MEAN
+{
+ Text [ en-US ] = "Mean";
+};
+
+String SID_CALC_STD_ERROR
+{
+ Text [ en-US ] = "Standard Error";
+};
+
+String SID_CALC_MODE
+{
+ Text [ en-US ] = "Mode";
+};
+
+String SID_CALC_MEDIAN
+{
+ Text [ en-US ] = "Median";
+};
+
+String SID_CALC_VARIANCE
+{
+ Text [ en-US ] = "Variance";
+};
+
+String SID_CALC_STD_DEVIATION
+{
+ Text [ en-US ] = "Standard Deviation";
+};
+
+String SID_CALC_KURTOSIS
+{
+ Text [ en-US ] = "Kurtosis";
+};
+
+String SID_CALC_SKEWNESS
+{
+ Text [ en-US ] = "Skewness";
+};
+
+String SID_CALC_RANGE
+{
+ Text [ en-US ] = "Range";
+};
+
+String SID_CALC_MIN
+{
+ Text [ en-US ] = "Minimum";
+};
+
+String SID_CALC_MAX
+{
+ Text [ en-US ] = "Maximum";
+};
+
+String SID_CALC_SUM
+{
+ Text [ en-US ] = "Sum";
+};
+
+String SID_CALC_COUNT
+{
+ Text [ en-US ] = "Count";
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index 60da88491796..02ef88bfb86f 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -269,6 +269,7 @@ void ScDLL::Init()
ScRandomNumberGeneratorDialogWrapper::RegisterChildWindow(false, pMod);
ScSamplingDialogWrapper ::RegisterChildWindow(false, pMod);
+ ScDescriptiveStatisticsDialogWrapper::RegisterChildWindow(false, pMod);
// First docking Window for Calc
ScFunctionChildWindow ::RegisterChildWindow(false, pMod);
diff --git a/sc/source/ui/inc/DescriptiveStatisticsDialog.hxx b/sc/source/ui/inc/DescriptiveStatisticsDialog.hxx
new file mode 100644
index 000000000000..edf08b6f8721
--- /dev/null
+++ b/sc/source/ui/inc/DescriptiveStatisticsDialog.hxx
@@ -0,0 +1,78 @@
+/* -*- 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 DESCRIPTIVE_STATISTICS_DIALOG_HXX
+#define DESCRIPTIVE_STATISTICS_DIALOG_HXX
+
+#include "global.hxx"
+#include "address.hxx"
+#include "anyrefdg.hxx"
+
+#include <vcl/fixed.hxx>
+#include <vcl/group.hxx>
+#include <vcl/lstbox.hxx>
+
+class ScDescriptiveStatisticsDialog : public ScAnyRefDlg
+{
+public:
+ ScDescriptiveStatisticsDialog(
+ SfxBindings* pB, SfxChildWindow* pCW,
+ Window* pParent, ScViewData* pViewData );
+
+ virtual ~ScDescriptiveStatisticsDialog();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ virtual void SetActive();
+ virtual sal_Bool Close();
+
+private:
+ // Widgets
+ FixedText* mpInputRangeLabel;
+ formula::RefEdit* mpInputRangeEdit;
+ formula::RefButton* mpInputRangeButton;
+
+ FixedText* mpOutputRangeLabel;
+ formula::RefEdit* mpOutputRangeEdit;
+ formula::RefButton* mpOutputRangeButton;
+
+ PushButton* mpButtonApply;
+ OKButton* mpButtonOk;
+ CancelButton* mpButtonCancel;
+
+ //
+ formula::RefEdit* mpActiveEdit;
+
+ // Data
+ ScViewData* mViewData;
+ ScDocument* mDocument;
+
+ ScRange mInputRange;
+ ScAddress::Details mAddressDetails;
+ ScAddress mOutputAddress;
+
+ ScAddress mCurrentAddress;
+
+ bool mDialogLostFocus;
+
+ void Init();
+ void GetRangeFromSelection();
+ void ApplyCalculationsFormulas();
+
+ DECL_LINK( OkClicked, PushButton* );
+ DECL_LINK( CancelClicked, PushButton* );
+ DECL_LINK( ApplyClicked, PushButton* );
+ DECL_LINK( GetFocusHandler, Control* );
+ DECL_LINK( LoseFocusHandler, void* );
+};
+
+#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 7c1e7d0150d0..b0490f373efc 100644
--- a/sc/source/ui/inc/reffact.hxx
+++ b/sc/source/ui/inc/reffact.hxx
@@ -52,6 +52,7 @@ DECL_WRAPPER_WITHID(ScHighlightChgDlgWrapper)
DECL_WRAPPER_WITHID(ScRandomNumberGeneratorDialogWrapper)
DECL_WRAPPER_WITHID(ScSamplingDialogWrapper)
+DECL_WRAPPER_WITHID(ScDescriptiveStatisticsDialogWrapper)
class ScAcceptChgDlgWrapper: public SfxChildWindow
{
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 489763953595..8a248143242f 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -173,6 +173,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
case FID_FILL_SERIES: // fill block
case SID_OPENDLG_RANDOM_NUMBER_GENERATOR:
case SID_SAMPLING_DIALOG:
+ case SID_DESCRIPTIVE_STATISTICS_DIALOG:
case SID_OPENDLG_TABOP: // multiple-cell operations, are at least 2 cells marked?
if (pDoc->GetChangeTrack()!=NULL &&nWhich ==SID_OPENDLG_TABOP)
bDisable = sal_True;
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 15953b3f3e2f..829269be546a 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -921,6 +921,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
}
break;
+ case SID_DESCRIPTIVE_STATISTICS_DIALOG:
+ {
+ sal_uInt16 nId = ScDescriptiveStatisticsDialogWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ }
+ break;
+
//
// disposal (Outlines)
// SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx
index 65adb74eac06..7de5b00bda05 100644
--- a/sc/source/ui/view/reffact.cxx
+++ b/sc/source/ui/view/reffact.cxx
@@ -53,6 +53,8 @@ SFX_IMPL_MODELESSDIALOG_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF )
SFX_IMPL_MODELESSDIALOG_WITHID(ScRandomNumberGeneratorDialogWrapper, SID_OPENDLG_RANDOM_NUMBER_GENERATOR )
SFX_IMPL_MODELESSDIALOG_WITHID(ScSamplingDialogWrapper, SID_SAMPLING_DIALOG )
+SFX_IMPL_MODELESSDIALOG_WITHID(ScDescriptiveStatisticsDialogWrapper, SID_DESCRIPTIVE_STATISTICS_DIALOG )
+
SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin, SID_VALIDITY_REFERENCE)
@@ -132,6 +134,9 @@ IMPL_CHILD_CTOR( ScRandomNumberGeneratorDialogWrapper, SID_OPENDLG_RANDOM_NUMBER
IMPL_CHILD_CTOR( ScSamplingDialogWrapper, SID_SAMPLING_DIALOG )
+IMPL_CHILD_CTOR( ScDescriptiveStatisticsDialogWrapper, SID_DESCRIPTIVE_STATISTICS_DIALOG )
+
+
//-------------------------------------------------------------------------
// ScSimpleRefDlgWrapper
//-------------------------------------------------------------------------
diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx
index 699a29df406a..79e9d3ac747e 100644
--- a/sc/source/ui/view/tabvwsh.cxx
+++ b/sc/source/ui/view/tabvwsh.cxx
@@ -83,6 +83,7 @@ SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL))
SFX_CHILDWINDOW_REGISTRATION(ScRandomNumberGeneratorDialogWrapper::GetChildWindowId());
SFX_CHILDWINDOW_REGISTRATION(ScSamplingDialogWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScDescriptiveStatisticsDialogWrapper::GetChildWindowId());
}
SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" )
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 0b169bfd5feb..ded42d12cfd6 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -63,6 +63,7 @@
#include "RandomNumberGeneratorDialog.hxx"
#include "SamplingDialog.hxx"
+#include "DescriptiveStatisticsDialog.hxx"
//------------------------------------------------------------------
@@ -328,6 +329,13 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
}
break;
+ case SID_DESCRIPTIVE_STATISTICS_DIALOG:
+ {
+ ScViewData* pViewData = GetViewData();
+ pResult = new ScDescriptiveStatisticsDialog( pB, pCW, pParent, pViewData );
+ }
+ break;
+
case SID_OPENDLG_OPTSOLVER:
{
ScViewData* pViewData = GetViewData();
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index a40fab3204c0..90412ea3ea08 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -477,6 +477,7 @@
<menu:menu menu:id=".uno:StatisticsMenu">
<menu:menupopup>
<menu:menuitem menu:id=".uno:SamplingDialog"/>
+ <menu:menuitem menu:id=".uno:DescriptiveStatisticsDialog"/>
</menu:menupopup>
</menu:menu>
</menu:menupopup>
diff --git a/sc/uiconfig/scalc/ui/descriptivestatisticsdialog.ui b/sc/uiconfig/scalc/ui/descriptivestatisticsdialog.ui
new file mode 100644
index 000000000000..b6040b42c2e6
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/descriptivestatisticsdialog.ui
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <!-- interface-requires LibreOffice 1.0 -->
+ <object class="GtkDialog" id="DescriptiveStatisticsDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Descriptive Statistics</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">2</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="apply">
+ <property name="label">gtk-apply</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="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">1</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="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>
+ </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="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>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</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>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="foruilo-RefButton" id="input-range-button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">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="xalign">0</property>
+ <property name="label" translatable="yes">Output Range</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">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>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="foruilo-RefButton" id="output-range-button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">apply</action-widget>
+ <action-widget response="0">ok</action-widget>
+ <action-widget response="0">cancel</action-widget>
+ </action-widgets>
+ </object>
+</interface>